[{"data":1,"prerenderedAt":585},["ShallowReactive",2],{"article-c-6-0-new-features":3},{"article":4,"tags":319,"previous":333,"next":398},{"id":5,"title":6,"author":7,"body":8,"createdAt":309,"description":310,"extension":311,"img":298,"meta":312,"navigation":313,"path":314,"seo":315,"stem":316,"tags":317,"updatedAt":309,"__hash__":318},"articles\u002Farticles\u002Fc-6-0-new-features.md","C# 6.0 New Features","[object Object]",{"type":9,"value":10,"toc":307},"minimark",[11,15,22,46,61,73,130,136,145,148,163,177,202,208,217,220,235,241,251,256,286,303],[12,13,14],"p",{},"The following features require the C# 6.0 compiler which is included in Visual Studio 2015.  Remarkably however C# 6 new features does not require and updated version of Microsoft .NET Framework (i.e. as long as you compile with VS.NET 2015 the features still work against .NET Framework 4).  This is possible as the features are implemented in the compiler itself and do not have dependencies on the .NET Framework.",[12,16,17,18,21],{},"1.) Using Static",[19,20],"br",{},"\nUsing static directives for System.ConsoleColor looks like (as well as System.IO.Directory)",[23,24,29],"pre",{"className":25,"code":26,"language":27,"meta":28,"style":28},"language-csharp shiki shiki-themes github-light github-dark","using static System.ConsoleColor;  \nusing static System.IO.Directory;  \n","csharp","",[30,31,32,40],"code",{"__ignoreMap":28},[33,34,37],"span",{"class":35,"line":36},"line",1,[33,38,39],{},"using static System.ConsoleColor;  \n",[33,41,43],{"class":35,"line":42},2,[33,44,45],{},"using static System.IO.Directory;\n",[23,47,49],{"className":25,"code":48,"language":27,"meta":28,"style":28},"ForegroundColor = Yellow;  \nstring[] files = GetFiles(directoryPath, searchPattern, System.IO.SearchOption.AllDirectories);  \n",[30,50,51,56],{"__ignoreMap":28},[33,52,53],{"class":35,"line":36},[33,54,55],{},"ForegroundColor = Yellow;  \n",[33,57,58],{"class":35,"line":42},[33,59,60],{},"string[] files = GetFiles(directoryPath, searchPattern, System.IO.SearchOption.AllDirectories);\n",[12,62,63,64,66,67,69,70,72],{},"These enable the invocation of numerous methods, properties and enums directly.  In each case, this eliminates the need to qualify the static member with its type.",[19,65],{},"\n ",[19,68],{},"\n2.) The nameof operator",[19,71],{},"\nThis is a new contextual keyword to identify a string literal that extracts a constant for (at compile time) the unqualified name of whatever identifier is specified as an argument.  The nameof(filename) returns “filename,” the name of the Encrypt method’s parameter.  However, nameof works with any programmatic identifier.  By leveraging the nameof operator, it’s possible to eliminate the vast majority of “magic” strings that refer to code identifiers as long as they’re in scope. This not only eliminates runtime errors due to misspellings within the magic strings, which are never verified by the complier, but also enables refactoring tools like Rename to update all references to the name change identifier.",[23,74,76],{"className":25,"code":75,"language":27,"meta":28,"style":28},"private static void Encrypt(string filename)  \n  {  \n    if (!Exists(filename)) \u002F\u002F LOGIC ERROR: Using Directory rather than File  \n    {  \n      throw new ArgumentException(\"The file does not exist.\",   \n        nameof(filename));  \n    }  \n    \u002F\u002F ...  \n  }\n",[30,77,78,83,88,94,100,106,112,118,124],{"__ignoreMap":28},[33,79,80],{"class":35,"line":36},[33,81,82],{},"private static void Encrypt(string filename)  \n",[33,84,85],{"class":35,"line":42},[33,86,87],{},"  {  \n",[33,89,91],{"class":35,"line":90},3,[33,92,93],{},"    if (!Exists(filename)) \u002F\u002F LOGIC ERROR: Using Directory rather than File  \n",[33,95,97],{"class":35,"line":96},4,[33,98,99],{},"    {  \n",[33,101,103],{"class":35,"line":102},5,[33,104,105],{},"      throw new ArgumentException(\"The file does not exist.\",   \n",[33,107,109],{"class":35,"line":108},6,[33,110,111],{},"        nameof(filename));  \n",[33,113,115],{"class":35,"line":114},7,[33,116,117],{},"    }  \n",[33,119,121],{"class":35,"line":120},8,[33,122,123],{},"    \u002F\u002F ...  \n",[33,125,127],{"class":35,"line":126},9,[33,128,129],{},"  }\n",[12,131,132,133,135],{}," ",[19,134],{},"\n3.) String Interpolation – this is an easier one to grasp.  This is the before syntax…",[23,137,139],{"className":25,"code":138,"language":27,"meta":28,"style":28},"string.Format(\"Hello!  My name is {0} {1} and I am {2} years old.\", person.FirstName, person.LastName, person.Age);\n",[30,140,141],{"__ignoreMap":28},[33,142,143],{"class":35,"line":36},[33,144,138],{},[12,146,147],{},"after…",[23,149,151],{"className":25,"code":150,"language":27,"meta":28,"style":28},"$\"Hello!  My name is {person.FirstName} {person.LastName} \n            and I am {person.Age} years old.\";\n",[30,152,153,158],{"__ignoreMap":28},[33,154,155],{"class":35,"line":36},[33,156,157],{},"$\"Hello!  My name is {person.FirstName} {person.LastName} \n",[33,159,160],{"class":35,"line":42},[33,161,162],{},"            and I am {person.Age} years old.\";\n",[12,164,165,166,66,168,170,171,173,174,176],{},"The string interpolation syntax reduces errors caused by arguments following the format string that are in improper order, or missing altogether and causing an exception.",[19,167],{},[19,169],{},"\n4.) Null-Conditional Operator",[19,172],{},"\nC# 6.0 introduces the “?.” operator known as the null-conditional operator.  The null-conditional operator translates to checking whether the operand is null prior to invoking the method or property.  What makes the null-conditional operator especially convenient is that it can be chained. If, for example, you invoke string",[33,175],{}," names = person?.Name?.Split(' '), Split will only be invoked if both person and person.Name are not null. When chained, if the first operand is null, the expression evaluation is short-circuited, and no further invocation within the expression call chain will occur.",[23,178,180],{"className":25,"code":179,"language":27,"meta":28,"style":28},"\u002F\u002Fafter  \nswitch (args?.Length) {}  \n\u002F\u002Fbefore  \n(args != null) ? (int?)args.Length : null  \n",[30,181,182,187,192,197],{"__ignoreMap":28},[33,183,184],{"class":35,"line":36},[33,185,186],{},"\u002F\u002Fafter  \n",[33,188,189],{"class":35,"line":42},[33,190,191],{},"switch (args?.Length) {}  \n",[33,193,194],{"class":35,"line":90},[33,195,196],{},"\u002F\u002Fbefore  \n",[33,198,199],{"class":35,"line":96},[33,200,201],{},"(args != null) ? (int?)args.Length : null\n",[12,203,204,205,207],{},"5.) Auto-Property Improvements",[19,206],{},"\nGetter-only auto-properties are a C# 6.0 feature for declaring read-only properties that are backed (internally) by a read-only field. As such, these properties can only be modified from within the constructor.  Rather than the six or so lines needed to declare a read-only property and initialize it prior to C# 6.0, now a single-line declaration and the assignment from within the constructor are all that’s needed.",[23,209,211],{"className":25,"code":210,"language":27,"meta":28,"style":28},"public ConsoleColor ForegroundColorVerbose { get; }\n",[30,212,213],{"__ignoreMap":28},[33,214,215],{"class":35,"line":36},[33,216,210],{},[12,218,219],{},"A second auto-property feature introduced in C# 6.0 is support for initializers.",[23,221,223],{"className":25,"code":222,"language":27,"meta":28,"style":28},"static private Lazy\u003CConsoleConfiguration>\nDefaultConfig{ get; } = new Lazy\u003CConsoleConfiguration>(() => new ConsoleConfiguration());\n",[30,224,225,230],{"__ignoreMap":28},[33,226,227],{"class":35,"line":36},[33,228,229],{},"static private Lazy\u003CConsoleConfiguration>\n",[33,231,232],{"class":35,"line":42},[33,233,234],{},"DefaultConfig{ get; } = new Lazy\u003CConsoleConfiguration>(() => new ConsoleConfiguration());\n",[12,236,237,238,240],{},"6.) Expression Bodied Methods and Auto-Properties",[19,239],{},"\nThis feature exists for both properties and methods and allows the use of the arrow operator (=>) to assign an expression to either a property or method in place of a statement body.",[23,242,244],{"className":25,"code":243,"language":27,"meta":28,"style":28},"static public ConsoleConfiguration GetDefault() => DefaultConfig.Value;  \n",[30,245,246],{"__ignoreMap":28},[33,247,248],{"class":35,"line":36},[33,249,250],{},"static public ConsoleConfiguration GetDefault() => DefaultConfig.Value;\n",[12,252,132,253,255],{},[19,254],{},"\n6.) Exception Improvements – ability to use a when clause to do additional filtering when an exception is thrown",[23,257,259],{"className":25,"code":258,"language":27,"meta":28,"style":28},"try { \n        \u002F\u002F Do stuff\n    } catch (Exception e) when ((DateTime.Now.DayOfWeek == DayOfWeek.Saturday) {\n        \u002F\u002F Swallow \n    }\n",[30,260,261,266,271,276,281],{"__ignoreMap":28},[33,262,263],{"class":35,"line":36},[33,264,265],{},"try { \n",[33,267,268],{"class":35,"line":42},[33,269,270],{},"        \u002F\u002F Do stuff\n",[33,272,273],{"class":35,"line":90},[33,274,275],{},"    } catch (Exception e) when ((DateTime.Now.DayOfWeek == DayOfWeek.Saturday) {\n",[33,277,278],{"class":35,"line":96},[33,279,280],{},"        \u002F\u002F Swallow \n",[33,282,283],{"class":35,"line":102},[33,284,285],{},"    }\n",[12,287,132,288,290],{},[19,289],{},[291,292,294],"a",{"href":293},"\u002Farticles\u002Fimages\u002Fopen-live-writer-c-60-new-features_12307-c6_2.jpg",[295,296],"img",{"style":297,"src":298,"border":299,"alt":300,"title":300,"width":301,"height":302},"background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;","\u002Farticles\u002Fimages\u002Fopen-live-writer-c-60-new-features_12307-c6_thumb.jpg",0,"c6",240,135,[304,305,306],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":28,"searchDepth":42,"depth":42,"links":308},[],"2016-11-09T14:21:45.8700000-05:00",null,"md",{},true,"\u002Farticles\u002Fc-6-0-new-features",{"title":6,"description":310},"articles\u002Fc-6-0-new-features",[27],"uMgZQ3TZwQfUVBOXbej-F7xUUHGEeZcIbN5MlW-pDw4",[320],{"id":321,"title":322,"body":323,"description":310,"extension":311,"img":327,"meta":328,"name":27,"navigation":313,"path":329,"seo":330,"stem":331,"__hash__":332},"tags\u002Ftags\u002Fcsharp.md","Csharp",{"type":9,"value":324,"toc":325},[],{"title":28,"searchDepth":42,"depth":42,"links":326},[],"https:\u002F\u002Fimages.unsplash.com\u002Fphoto-1598313183973-4effcded8d5e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=675&q=80",{},"\u002Ftags\u002Fcsharp",{"description":310},"tags\u002Fcsharp","q__D01bgRc46igktetL1XSIb0CS3jpaQOtnTfdNZJyQ",{"id":334,"title":335,"author":7,"body":336,"createdAt":390,"description":391,"extension":311,"img":385,"meta":392,"navigation":313,"path":393,"seo":394,"stem":395,"tags":396,"updatedAt":390,"__hash__":397},"articles\u002Farticles\u002Ffind-all-tables-containing-column-with-specified-name.md","Find all tables containing column with specified name",{"type":9,"value":337,"toc":388},[338,341,378,386],[12,339,340],{},"In order to find a column name anywhere it is used in a table or view I was able to use the\nfollowing SQL…",[23,342,346],{"className":343,"code":344,"language":345,"meta":28,"style":28},"language-sql shiki shiki-themes github-light github-dark","SELECT      COLUMN_NAME AS 'ColumnName'  \n            ,TABLE_NAME AS  'TableName'  \nFROM        INFORMATION_SCHEMA.COLUMNS  \nWHERE       COLUMN_NAME LIKE '%columnnameyouarelookingfor%'  \nORDER BY    TableName  \n            ,ColumnName;  \n","sql",[30,347,348,353,358,363,368,373],{"__ignoreMap":28},[33,349,350],{"class":35,"line":36},[33,351,352],{},"SELECT      COLUMN_NAME AS 'ColumnName'  \n",[33,354,355],{"class":35,"line":42},[33,356,357],{},"            ,TABLE_NAME AS  'TableName'  \n",[33,359,360],{"class":35,"line":90},[33,361,362],{},"FROM        INFORMATION_SCHEMA.COLUMNS  \n",[33,364,365],{"class":35,"line":96},[33,366,367],{},"WHERE       COLUMN_NAME LIKE '%columnnameyouarelookingfor%'  \n",[33,369,370],{"class":35,"line":102},[33,371,372],{},"ORDER BY    TableName  \n",[33,374,375],{"class":35,"line":108},[33,376,377],{},"            ,ColumnName;\n",[291,379,382],{"style":380,"href":381},"display:none","\u002Farticles\u002Fimages\u002Fopen-live-writer-f5f906eb5cd0_bcd7-sql_2.png",[295,383],{"title":345,"style":384,"border":299,"alt":345,"src":385,"width":301,"height":301},"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px;display='none';","\u002Farticles\u002Fimages\u002Fopen-live-writer-f5f906eb5cd0_bcd7-sql_thumb.png",[304,387,306],{},{"title":28,"searchDepth":42,"depth":42,"links":389},[],"2017-01-14T06:29:42.0000000-05:00","Find a column name anywhere.",{},"\u002Farticles\u002Ffind-all-tables-containing-column-with-specified-name",{"title":335,"description":391},"articles\u002Ffind-all-tables-containing-column-with-specified-name",[345],"D4x_b6dLDTOhJk_oDi11rJkwS-ARV4n6opJh-YLJXvE",{"id":399,"title":400,"author":7,"body":401,"createdAt":576,"description":577,"extension":311,"img":416,"meta":578,"navigation":313,"path":579,"seo":580,"stem":581,"tags":582,"updatedAt":576,"__hash__":584},"articles\u002Farticles\u002Fxamarin-player-failed-to-initialize-device-nexus4.md","Xamarin Player Failed to initialize device Nexus4",{"type":9,"value":402,"toc":574},[403,406,409,419,426,441,445,448,464,467,490,493,502,514,517,526,529,541,553,562,565],[12,404,405],{},"What’s going on?  I want to run my Android emulator (XAP – Xamarin Android Player) and I get the following issue.",[12,407,408],{},"“Failed to initialize device”, “VboxMessage command failed: See log for further details”",[12,410,411],{},[291,412,414],{"href":413},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-xamarin-player-failed-to-initialize-devi_ae14-image_2.png",[295,415],{"style":297,"src":416,"border":299,"alt":417,"title":417,"width":301,"height":418},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-xamarin-player-failed-to-initialize-devi_ae14-image_thumb.png","image",133,[12,420,421,422],{},"Ok, what’s going on today with my Xamarin Player.  A bit of Google-ing came up with the following information announced at the 2016 Evolve conference. \u003C\n",[423,424,425],"strong",{},"New Mac OS X Universal Installer",[12,427,428,429,432,433,436,437,440],{},"To streamline development setup on Mac OS X, we have introduced a brand ",[423,430,431],{},"new universal installer",". This will not only handle updating to the latest version of Xamarin, but also will ",[423,434,435],{},"setup the new and improved Android Emulators from Google",", based on x86 HAXM, that are now ",[423,438,439],{},"10 times faster then before!"," If you are on Windows using Visual Studio be sure to checkout the Hyper-V enabled",[291,442,444],{"href":443},"https:\u002F\u002Fwww.visualstudio.com\u002Fen-us\u002Ffeatures\u002Fmsft-android-emulator-vs.aspx","\nVisual Studio Emulators for Android",[423,446,447],{},"Xamarin Android Player is now officially deprecated",[12,449,450,451,454,455,457,458],{},"Wow - ",[423,452,453],{},"Xamarin Android Player is now officially deprecated – ","This honestly was a surprise as it had worked so well for me in the past.",[19,456],{},"\nSo as instructed checking out the Hyper-V enabled ",[291,459,461],{"href":443,"target":460},"_blank",[423,462,463],{},"Visual Studio Emulators for Android",[12,465,466],{},"I downloaded, installed the emulator promising “The x86 emulator boots and runs at nearly the speed of a physical device, making debugging a breeze on graphics-intensive, processor-hungry apps.”",[12,468,132,469,476,478,479,66,481,483],{},[291,470,472],{"href":471},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-xamarin-player-failed-to-initialize-devi_ae14-image7.png",[295,473],{"style":297,"src":474,"border":299,"alt":417,"title":417,"width":475,"height":301},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-xamarin-player-failed-to-initialize-devi_ae14-image7_thumb.png",171,[19,477],{},"\n \n \nAfter the installation, I was required to restart.  I opened my Android-Xamarin app thinking I would find this emulator choice in the Visual Studio Device drop down.  Nope.  I found ‘Visual Studio Emulator for Android’ as a recently installed application.  I soon made that attached to my task bar for ease of finding next time.  Starting it, I was challenged with the next hurdle. “You do not have permission to modify internal Hyper-V network adapter settings, which are required to run the emulator” – I hit ‘Retry’ and it appears to be running with the",[19,480],{},[19,482],{},[291,484,486],{"href":485},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-xamarin-player-failed-to-initialize-devi_ae14-image_4.png",[295,487],{"style":297,"src":488,"border":299,"alt":417,"title":417,"width":301,"height":489},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-xamarin-player-failed-to-initialize-devi_ae14-image_thumb_1.png",142,[12,491,492],{},"I hit ‘Retry’ and it appears to be running with the following notification.  Still preparing, I am starting to wonder if anything is going on. ",[12,494,495],{},[291,496,498],{"href":497},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-xamarin-player-failed-to-initialize-devi_ae14-image_8.png",[295,499],{"style":297,"src":500,"border":299,"alt":417,"title":417,"width":301,"height":501},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-xamarin-player-failed-to-initialize-devi_ae14-image_thumb_3.png",37,[12,503,504,505,507],{},"Bang – I am starting to see something with “OS – Starting” and I now see the emulator.  Whew.",[19,506],{},[291,508,510],{"href":509},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-xamarin-player-failed-to-initialize-devi_ae14-image_10.png",[295,511],{"style":297,"src":512,"border":299,"alt":417,"title":417,"width":513,"height":301},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-xamarin-player-failed-to-initialize-devi_ae14-image_thumb_4.png",134,[12,515,516],{},"Checking things out, clicking around I try the web browser, and given another test of my competence.  So the problem is, I cannot browse to the internet via the Android Emulator default browser.",[12,518,519],{},[291,520,522],{"href":521},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-xamarin-player-failed-to-initialize-devi_ae14-image_12.png",[295,523],{"style":297,"src":524,"border":299,"alt":417,"title":417,"width":301,"height":525},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-xamarin-player-failed-to-initialize-devi_ae14-image_thumb_5.png",89,[12,527,528],{},"I uninstalled Xamarin Android Player – figuring I didn’t need this any more ..moment of silence please.",[12,530,531,532,534],{},"Ok, so using a few of my Sherlock skills I opened up Hyper-V Manager (found via start search).  Select the emulator then the settings option for that emulator.",[19,533],{},[291,535,537],{"href":536},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-xamarin-player-failed-to-initialize-devi_ae14-image_14.png",[295,538],{"style":297,"src":539,"border":299,"alt":417,"title":417,"width":301,"height":540},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-xamarin-player-failed-to-initialize-devi_ae14-image_thumb_6.png",126,[12,542,543,544,546],{},"I then selected the ‘Emulator External Network Adaptor” and chose my physical network adapter, closed\u002Fshutdown the emulator and restarted.  Great- challenge completed and all seems to be working.",[19,545],{},[291,547,549],{"href":548},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-xamarin-player-failed-to-initialize-devi_ae14-image_16.png",[295,550],{"style":297,"src":551,"border":299,"alt":417,"title":417,"width":301,"height":552},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-xamarin-player-failed-to-initialize-devi_ae14-image_thumb_7.png",225,[12,554,555],{},[291,556,558],{"href":557},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-xamarin-player-failed-to-initialize-devi_ae14-image_18.png",[295,559],{"style":297,"src":560,"border":299,"alt":417,"title":417,"width":561,"height":301},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-xamarin-player-failed-to-initialize-devi_ae14-image_thumb_8.png",172,[12,563,564],{},"Circling back to my Visual Studio – I am not able to use the Visual Studio Android emulator by selecting the appropriate device.  I have successfully removed the Xamarin Android Player, installed the new\u002Fimproved Visual Studio Emulator and made modifications via Hyper-V Manager to set the network connection of the device to my local hardware on my pc.",[12,566,567],{},[291,568,570],{"href":569},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-xamarin-player-failed-to-initialize-devi_ae14-image_20.png",[295,571],{"style":297,"src":572,"border":299,"alt":417,"title":417,"width":301,"height":573},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-xamarin-player-failed-to-initialize-devi_ae14-image_thumb_9.png",38,{"title":28,"searchDepth":42,"depth":42,"links":575},[],"2016-06-12T06:39:07.8500000-04:00","Failed to initialize...",{},"\u002Farticles\u002Fxamarin-player-failed-to-initialize-device-nexus4",{"title":400,"description":577},"articles\u002Fxamarin-player-failed-to-initialize-device-nexus4",[583],"xamarin","-lzYhCSoLfeLoNk6Ny6UBEB46Y35mtv4t2kMDAnjhGE",1781574763322]