Skip to content

Instantly share code, notes, and snippets.

public class Role : Enumeration<Role>
{
public static readonly Role System = new Role(0, "System", "System", true);
public static readonly Role Manager = new Role(1, "Manager", "Michelle", false);
public static readonly Role Employee = new Role(2, "Employee", "Eric", false);
public static readonly Role HumanResources = new Role(3, "Human Resources", "Harry", false);
private Role(int value, string displayName, string personaName, bool testrole)
: base(value, displayName)
{
Role manager = (Role)(1);
Role bogus = (Role)(-1);
Console.WriteLine(manager);
Console.WriteLine(bogus);
//Output:
// Manager
// -1
public void ReceiveLambdaAsDelegate(Func<int, int> function) {...}
public void ReceiveLambdaAsExpression(Expression<Func<int, int>> expression) {...}
...
ReceiveLambdaAsDelegate(x => x*x);
ReceiveLambdaAsExpression(x => x*x);
public void ReceiveLambdaAsDelegate(Func<int, int> function) {...}
public void ReceiveLambdaAsExpression(Expression<Func<int, int>> expression) {...}
...
ReceiveLambdaAsDelegate(x => x*x);
ReceiveLambdaAsExpression(x => x*x);
//Discovering all method declarations in a given tree:
IEnumerable<MethodDeclarationSyntax> methods =
tree.Root
.DescendentNodes()
.OfType<MethodDeclarationSyntax>().ToList();
public static Customer GetCustomer(Guid customerID)
{
return CustomerDataAccess.GetCustomer(customerID);
}
public static Customer GetCustomer(Guid customerID)
{
try
{
return CustomerDataAccess.GetCustomer(customerID);
}
catch (SomeSpecialException)
{
throw;
}
public static Customer GetCustomer(Guid customerID)
{
try
{
return CustomerDataAccess.GetCustomer(customerID);
}
catch (Exception ex)
{
Handle(ex);
}
public static Customer GetCustomer(Guid customerID)
{
try
{
return CustomerDataAccess.GetCustomer(customerID);
}
catch (Exception ex)
{
Handle(ex);
}
using Some.Imaginary.Macro.Library;
public class Sample
{
prop public string Name;
}