csharp C#代码

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp C#代码相关的知识,希望对你有一定的参考价值。

// csc /target:winexe /nowin32manifest cbdropr.cs
using System;
using System.Windows.Forms;

namespace QWERTY {
    public class cbdropr:Form {
        void onEnter(object sender, DragEventArgs e) {
            e.Effect = DragDropEffects.Copy;
        }

        void onDrop(object sender, DragEventArgs e) {
            string url = e.Data.GetData(typeof(string)) as string;
            System.Diagnostics.Process.Start("f.bat", url);
        }
        
        public cbdropr() {
            this.AllowDrop = true;
            this.DragEnter += new DragEventHandler(this.onEnter);
            this.DragDrop  += new DragEventHandler(this.onDrop);
        }
        
        [STAThread]
        public static void Main(String[] args) {
            Application.Run(new cbdropr());
        }
    }
}
//Compile using csc test.cs
using System;
using System.IO;
using System.Text;
using System.Linq;

public class Program
{
    static void Main(string[] args)
    {
        if (args.Any() &&File.Exists(args[0]))
        {
            var fs = new FileStream(args[0], FileMode.Open);
            var len = (int)fs.Length;
            var bits = new byte[len];
            fs.Read(bits, 0, len);

            int i =0, j = 0;
            for(i = 0; i < len; i++)
            {
                if((bits[i] & 0xF0) == 0x90)
                {
                    j++;
                }
            }

            Console.Write("Reading "+i+ " bytes..");
            Console.Write(" Count: "+j+"\n");
            Console.ReadLine();
        }
    }
}

以上是关于csharp C#代码的主要内容,如果未能解决你的问题,请参考以下文章

csharp FTP代码c#

csharp C#代码

csharp 非同步上传档案后端C#代码

csharp 用于SQL CRUD操作的常用C#代码段

csharp 一种衡量C#代码任何部分执行时间的方法。

csharp 基于Wikipedia伪代码的C#中的MD5实现