人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統下載站 > 技術開發教程 > 詳細頁面

C#學習筆記之一(basic, class, function,array, collection interface)

C#學習筆記之一(basic, class, function,array, collection interface)

更新時間:2022-06-25 文章作者:未知 信息來源:網絡 閱讀次數:

最近學習了C#程序設計的課程, 現在將筆記總結如下, 沒有系統整理,都是課上記得notes, 后面幾部分以程序居多,因為這些筆記沒有做過整理,所以很多code沒有詳細的注釋,如果有時間的話,我會對筆記做系統的整理,還有這里沒有提及基本的語法介紹,望大家諒解:

Basic:
//利用out, 不用給i,j assign初始值
int i,j;
f(out i, out j) {}
//using, 括號外自動destroy對象
using (Font theFont == new Font("Ariel", 10.0f)){}
//constants
const int i = 32;
//Enumeration
enum E {a=5,b=8}
int i = (int) E.a;
//turn buff data to string
Encoding.ASCII.GetString(buff, 0, bytesRead)
// read data
string s = Console.ReadLine()
int j= Convert.ToInt32(s);
//get textbox value and convert to double
double left = double.Parse(textBox1.Text);
Application.DoEvent(); //this will let app deal with event
array:
A[] a = new A[5]; // a[0]to a[5] is null
int[] arr = new int[2] {1,2}
int[] arr = {2,3,4,5}
foreach(A a in arr_A) {}
for(int i=0; i<arr.Length; i++) {}
//Rectangular Arrays
int[,] rectArray = new int[4,5]
int[,] arr = {{1,2,3,4},{1,2,3,4}{1,2,3,4}}; //init
//Jagged array, 數組中包含數組,各維不等長
// ja[0].Length is length of ja[0]
int [][] ja = new int[4][];
//using params transfer a array to a function
//using f(1,2,3,4) to call the function
f(params int[] values){
foreach (int[] a in values) {}
}
Collection interface:
indexers:
//define a indexers
public Myclass this[int offset] {get{};set{}}
//call it
Employee joe = bostonOffice["Joe"];
IEnumerable:
//return a IEnumerator object
GetEnumerator()
IEnumerator:
Reset(){}
Current(){}
MoveNext(){}
IComparable:
//Class inherit IComparable interface
//Implement CompareTo() method
CompareTo()
ArrayLists:
Count Get number of elements
Add() Add an object
Clear() Remove all objects
Reverse() Reverse order of elements
Sort() Sort the elements
function:
//default by value
f(int x){}
//by reference
f(ref int x){}
class:
//存取:
public, private, protected, internal, protected internal
this, static //static member must be init in class
//繼承
class A: B {}
//多態
virtual,override
//init對象
Employee emp1 = new Employee();

//先隱式轉換3為Roman
Roman r4 = r1 + 3;
//先顯式轉換7.5為Roman
Roman r5 = r1 +(Roman)7.5;

// 運算符重載,先返回int, 然后用隱式轉換
public static Roman operator+ (Roman l, Roman r)
{
return (l.val+r.val);
}
//顯式轉換
public static explicit operator Roman(float val)
{
return new Roman(val);
}
//隱式轉換
public static implicit operator Roman(int val)
{
return new Roman(val);
}
//properties, 注意大小寫
public int Age {
get {return age;}
set {age = value;}
}

//Interface
//interface methods must be implement in class
public interface IA {}
//is 測試類是否從接口繼承
if (a is IA) {IA c = (IA) a; }
//as 測試類是否從接口繼承
IA c = a as IA;
if (c != null) {}
//interface properties
pubiic interface IAA: IA
{
float F{get;set;}
}
//mutiface interface inheritance
public class C: IA,

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

網站地圖xml | 網站地圖html
主站蜘蛛池模板: 海林市| 台北市| 松阳县| 阜平县| 焦作市| 兰西县| 威远县| 蓝山县| 邹城市| 陈巴尔虎旗| 壶关县| 无棣县| 老河口市| 栾城县| 普定县| 育儿| 甘洛县| 奉节县| 正定县| 石首市| 庄浪县| 石台县| 大邑县| 太保市| 集贤县| 陆丰市| 油尖旺区| 海盐县| 贵港市| 宁晋县| 会昌县| 东平县| 南陵县| 芜湖市| 鸡西市| 平果县| 漠河县| 陇西县| 大理市| 岐山县| 双峰县|