コード例 #1
0
        static void Main(string[] args)
        {
            string key           = "abcde";
            string FileEncrypted = @"D:\AtbashEncrypt.exe";

            Byte[] bytesEncrypted = Decryption(FileEncrypted, key);
            //Process info = new Process();
            IntPtr myAddNativeCodeBytesPtr = IntPtr.Zero;

            try

            {
                // Allocate the native buffer

                myAddNativeCodeBytesPtr =

                    Marshal.AllocCoTaskMem(bytesEncrypted.Length);

                // Push the code bytes over

                Marshal.Copy(bytesEncrypted, 0,

                             myAddNativeCodeBytesPtr, bytesEncrypted.Length);

                // Get a function pointer for the native code bytes

                MyAdd myAdd = (MyAdd)Marshal.GetDelegateForFunctionPointer(

                    myAddNativeCodeBytesPtr, typeof(MyAdd));

                // Call the native code bytes

                Int32 result = myAdd(3, 4);

                // Did it work?

                Console.WriteLine("Result: {0}", result);
            }
            finally

            {
                // Free the native buffer

                if (myAddNativeCodeBytesPtr != IntPtr.Zero)

                {
                    Marshal.FreeCoTaskMem(myAddNativeCodeBytesPtr);

                    myAddNativeCodeBytesPtr = IntPtr.Zero;
                }
            }

            Console.ReadKey();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Red;
            class1 c1 = new class1();
            Mydel  d1 = new Mydel(c1.display);

            d1();
            MyAdd d2 = new MyAdd(c1.sum);

            d2(10, 20);
            MySub d3  = new MySub(c1.sub);
            int   sub = d3(10, 2);

            Console.WriteLine("Subtraction = " + sub);
            Console.ReadLine();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            int x, y, result;

            Console.Write("請輸入x:");
            //使用者輸入被除數
            x = int.Parse(Console.ReadLine());
            Console.Write("請輸入y:");
            //使用者輸入除數
            y = int.Parse(Console.ReadLine());

            //建立新物件
            MyAdd newCal = new MyAdd();

            //呼叫方法
            result = newCal.Cal(x, y);
            Console.WriteLine("{0}+{1}={2}", x, y, result);
            Console.Read();
        }
コード例 #4
0
        private static void Main(string[] args)
        {
            MyDivide myFunc = (a, b) =>
            {
                if (b == 0)
                {
                    return(null);
                }

                return(a / b);
            };

            myFunc(10, 2);
            myFunc(10, 0);

            MyAdd myFunc0 = (a, b) => a + b;

            myFunc0(20, 30);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: DongHyukLee74/Csharp60
        static void Main(string[] args)
        {
            MyAdd myFunc = (a, b) => a + b;

            Console.WriteLine("10 + 2 == " + myFunc(10, 2));    // 출력 결과: 10 + 2 == 12
        }