static void Main(string[] args) { /*Access Modifiers*/ // -See Primitive Types Projects which is referencing this project to verify the examples PublicClass publicClass = new PublicClass(); //You can access a public class from anywhere, even outside the assembly InternalClass internalClass = new InternalClass(); //You can access an internal class from anywhere inside this assembly InternalClassChild internalClassChild = new InternalClassChild(); //internalClass.ProtectedMethod(); -Impossible since we can't invoke protected methods outside the class and it's children internalClassChild.InvokeParentProtectedMehtod(); //Protected method invoked through's child's public method //publicClass.PrivateMethod(); -Impossible since we can't invoke private method's outside a class publicClass.PublicMethod(); //Acessing the private method through a public method, helpful when performing Encapsulation //AbtractClass abtractClass = new AbtractClass(); -Impossible since we can't instanciate Abtract classes AbstractClass abtractClass = new ImplementingClass(); //ImplementingClass imlpements every method fromo Abstract class abtractClass.AbtractMethod(); //Virtual method that shares functionality between the base class and the child's class internalClassChild.VirtualMethod(); Console.WriteLine(StaticClass.StaticString); //For static classes, you do not need to create an instance, you can invoke the methods directly SealedClass sealedClass = new SealedClass(); //You can create instances of a sealed class, but you can't inherit from it Console.ReadLine(); }
static void Main() { SealedClass sc = new SealedClass(); sc.x = 110; sc.y = 150; Console.WriteLine("x = {0}, y = {1}", sc.x, sc.y); }
public static void SealedClassInterfaceMethod() { SealedClass aSealedClass = new SealedClass(); foreach (var iteration in Benchmark.Iterations) { using (iteration.StartMeasurement()) aSealedClass.InterfaceMethod(); } }
public void MethodWithSealedClassReturnTypeReturnsCorrectResult() { var substitute = Substitute.For<IInterface>(); var expected = new SealedClass(); substitute.MethodWithSealedClassReturnType().Returns(expected); var result = substitute.MethodWithSealedClassReturnType(); Assert.That(result, Is.EqualTo(expected)); }
public void MethodWithSealedClassReturnTypeReturnsCorrectResult() { var substitute = Substitute.For <IInterface>(); var expected = new SealedClass(); substitute.MethodWithSealedClassReturnType().Returns(expected); var result = substitute.MethodWithSealedClassReturnType(); Assert.That(result, Is.EqualTo(expected)); }
public static void Main() { SealedClass s = new SealedClass(); B b = new D2(); b.F(); // Calls D1.F() D2 d2 = new D2(); d2.F(); // Calls D2.F() }
public static void SealedClassInterfaceMethod() { SealedClass aSealedClass = new SealedClass(); foreach (var iteration in Benchmark.Iterations) { using (iteration.StartMeasurement()) for (int i = 0; i < Benchmark.InnerIterationCount; i++) { aSealedClass.InterfaceMethod(); } } }
private LoadedDocument CreateLoadedDocument(SealedClass @class, string namespaceName) { if (!IsConstructorTest) { @class.Constructors.Clear(); if (!IsNestedConstructorTest) { RemoveNestedConstructors(@class.Constructors, @class.Classes, @class.Structs); } } return(CreateLoadedDocument(@class, namespaceName, classes => classes.SealedClasses.Add(@class))); }
public static void Test(int param) { object instance; switch (param) { case 0: instance = SealedClass.Instance(); break; default: instance = AnnotatedClass.Instance(); break; } instance.GetType().GetMethod("UsedMethod"); }
static void Main() { // cannot do since SealedClass above has private constructor /* * SealedClass sc = new SealedClass(); * sc.x = 110; * sc.y = 150; * Console.WriteLine(sc.x + " " + sc.y); */ SealedClass sc = new SealedClass(5); Console.WriteLine(sc.x); // no issues accessing the constant inside teh sealed class. no instantiation is required. Console.WriteLine(SealedClass.const1); }
/* * IEnumerator, coroutine Linq is difficult, study agains * */ // Use this for initialization void Start() { ClassMember.Hoge (); ClassMember cm = new ClassMember (); cm.Mage (); StaticClass.Hoge (); SealedClass sc = new SealedClass (); sc.canExtended (); ExtendSealedClass esc = new ExtendSealedClass (); esc.canExtended (); ShowStruction ss = new ShowStruction (1, 2); Debug.Log (ss.x); TestBoxConvert (); // ShowCast show_cast = new ShowCast (); // show_cast.Main (); TestDelegate (); }
static void TestSealed() { s_sealedClassField = new SealedClass(); s_sealedClassField.GetType().GetMethod("Method"); }
public bool Third(SealedClass sealedC) { throw new NotImplementedException(); }
public ImplIClass2(SealedClass sealedClass1) { }
void OtherMethod2(SealedClass sc) { ISomeInterface t = (ISomeInterface)sc; // Does not compile! }