static void DelegatesConcept() { DelegatesClass obj = new DelegatesClass(); obj.TestMethod(5); bool result = obj.del2(10); Console.WriteLine(obj.del1()); //Changing the reference of the delegates to point to some other method obj.del1 = () => { return(false); };//Method3 Console.WriteLine(obj.del1()); Console.WriteLine(result); MyHelper.PrintPointsToRememberMessage(); Console.WriteLine("1. A delegate is a reference to a method."); Console.WriteLine("2. First we need to declare a delegate reference"); Console.WriteLine("3. Second we can assigned some method to the delegates"); Console.WriteLine("4. Finally we can call the delegates method."); MyHelper.PrintNoteConcept(); MyHelper.PrintEndMessage(); }
/// <summary> /// Checks if a given OpenGL function is supported by the current context /// </summary> /// <param name="function">The name of the OpenGL function (i.e. glShaderSource)</param> /// <returns>True if the function is supported, false otherwise</returns> public static bool SupportsFunction(string function) { lock (gl_lock) { if (function == null) { throw new ArgumentNullException("function"); } sb.Remove(0, sb.Length); if (!function.StartsWith("gl")) { sb.Append("gl"); } sb.Append(function); FieldInfo f = DelegatesClass.GetField(sb.ToString(), BindingFlags.Static | BindingFlags.NonPublic); if (f == null) { return(false); } return(f.GetValue(null) != null); } }
public DelegatesUser(DelegatesClass ds) { this.ds = ds; //... }