複製代碼 代碼如下:using System; using System.IO; using System.Text.RegularExpressions; using System.Threading; using System.Windows.Forms; using System.Net; namespace TrojanScanning { public partial class Form1 : Form { public Form1() { InitializeComponent()
C#預設情況下,若常數運算式的值超過了目標類型的最大值,將會導致編譯錯誤。若目標資料類型不能容納非常數運算式的資料,那麼資料在賦值時會被截斷。複製代碼 代碼如下:class Program { static void Main(string[] args) { int n = int.MaxValue;//n=2147483647 n = n + 1; System.Console.WriteLine(n); } } 此時可用記憶體儲存資料來解釋,之前int.MaxValue在記憶體為為32位1
複製代碼 代碼如下:using System; using System.IO; public class FileApp { public static void Main() { // 在目前的目錄建立一個檔案myfile.txt,對該檔案具有讀寫權限 FileStream fsMyfile = new FileStream("myfile.txt" , FileMode.Create, FileAccess.ReadWrite);
SQLHelper.cs複製代碼 代碼如下:using System; using System.Collections.Generic; using System.Text; using System.Collections; using System.Data; using System.Data.SqlClient; using System.Configuration; namespace HelloWinForm.DBUtility { class SQLHelper {
1.用Pascal規則來命名方法和類型。 public class DataGrid { public void DataBind() { } } 2.用Camel規則來命名局部變數和方法的參數. public class Product { private string _productId; private string _productName; public void AddProduct(string productId,string productName) { } }
複製代碼 代碼如下:# using System; # using System.Collections; # using System.Text; # # /// <summary> # /// Class for encoding and decoding a string to QuotedPrintable # /// RFC 1521 http://www.ietf.org/rfc/rfc1521.txt # /// RFC 2045