This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace ShortCircuitExample | |
{ | |
public class Program | |
{ | |
static void Main(string[] args) | |
{ | |
if (IsStoreOpen() && NeedGrocery()) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace NonShortCircuitExample | |
{ | |
public class Program | |
{ | |
static void Main(string[] args) | |
{ | |
if (IsStoreOpen() & NeedGrocery()) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace staticUsingExample | |
{ | |
public static class IdValidationHelper | |
{ | |
public static bool IsValid(string id) | |
{ | |
bool isValid = false; | |
// Validate id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace FastFailExample | |
{ | |
public class Program | |
{ | |
static void Main(string[] args) | |
{ | |
try | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace GlobalNamespaceAliasExample | |
{ | |
public class System | |
{ | |
public void Log(string message) | |
{ | |
// Code to log | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace GlobalNameSpaceAliasExample | |
{ | |
public class System | |
{ | |
public void Log(string message) | |
{ | |
global::System.Console.WriteLine(message); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Globalization; | |
namespace NumberStylesExample | |
{ | |
public class Program | |
{ | |
static void Main(string[] args) | |
{ | |
// A Hexadecimal number with trailing and leading white spaces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern alias assembly1; | |
namespace NamespaceAliasExample | |
{ | |
public class Program | |
{ | |
static void Main(string[] args) | |
{ | |
assembly1::SameNamespaceName.Class1.MethodA(); | |
SameNamespaceName.Class2.MethodB(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace SameNamespaceName | |
{ | |
public class Class2 | |
{ | |
public static void MethodB() | |
{ | |
var assemblyame = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name; | |
Console.WriteLine($"Assemble Name: {assemblyame}"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace SameNamespaceName | |
{ | |
public class Class1 | |
{ | |
public static void MethodA() | |
{ | |
var assemblyame = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name; | |
Console.WriteLine($"Assemble Name: {assemblyame}"); |