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.Diagnostics; | |
using System.Runtime.CompilerServices; | |
namespace staticUsingExample | |
{ | |
public static class Logger | |
{ | |
public static void Log(string message, | |
[CallerFilePath] string sourceFilePath = "", | |
[CallerLineNumber] int sourceLineNumber = 0, |
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 static staticUsingExample.Logger; | |
namespace staticUsingExample | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
DebugLog("Member Start"); |
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 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
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
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; | |
namespace SameNamespaceName | |
{ | |
public class Class1 | |
{ | |
public static void MethodA() | |
{ | |
var assemblyame = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name; | |
Console.WriteLine($"Assemble Name: {assemblyame}"); |