Last active
December 31, 2019 00:50
-
-
Save carlnc/9bcbefc73b35b148f85a2dfe7a4e8f66 to your computer and use it in GitHub Desktop.
C Sharp Reminders
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 SomeClass = System.IO.File; | |
namespace CarlTesting | |
{ | |
public delegate string SomthingHappenedDelecate(object sender, EventArgs evt); | |
public abstract class BaseClass | |
{ | |
public BaseClass(string arg1) { | |
} | |
public abstract void ImplementMe(string arg1); | |
} | |
public class MyClass : BaseClass { | |
public event SomthingHappenedDelecate SomethingHappened; | |
public int PublicNumberField = 4; | |
public string BasicPublicStringProperty { | |
get; | |
private set; | |
} | |
public string PublicStringProperty { | |
get { return privateString; } | |
set { privateString = value; } | |
} | |
private string privateString; | |
static MyClass() { | |
MyClass.FIRST = 3; | |
} | |
public MyClass() { | |
this.base("Arg1"); | |
// | |
} | |
public MyClass(string arg1): base(arg1) { | |
MyReadonlyString = arg1; | |
} | |
public void MyMethod() { | |
} | |
public static void MyStaticMethod() {} | |
readonly string MyReadonlyString = "DefaultInitialValue"; | |
const string MyReadOnlyString = "Blah"; | |
public static readonly int FIRST = 1; | |
public void CallMyDelegate() { | |
CallPassedInDelegate((object sender, EventArgs evt) => | |
{ | |
return "asdfasdf"; | |
}); | |
} | |
public void CallPassedInDelegate(SomthingHappenedDelecate someDelegate) | |
{ | |
var evt = new EventArgs(); | |
string result = someDelegate(this, evt); | |
// call listening delegates | |
SomethingHappened?.Invoke(this, evt); | |
} | |
public override void ImplementMe(string arg1) | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
public interface ISomeInterface | |
{ | |
// all methods are assumed to be public | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment