摘要:(200-06-11) VB.NET 教學 Enum
1.設定 Enum
Public Enum DBTypeEnum As Int32
SQLSERVER = 100
ORACLE = 300
SYBASE = 400
INFORMIX = 10
End Enum
2.使用Enum
Module TestSQLList
Public Sub Main()
'定義一個資料庫類型區域變數
Dim db As Int32 = 1
Select Case db
Case 1
Case 2
End Select
'使用常數
Dim db2 As Int32 = DBType.ORACLE
Select Case db2
Case DBType.INFORMIX
Case DBType.ORACLE
Case DBType.SQLSERVER
Case DBType.SYBASE
End Select
'使用列舉(侵入式系統 ()
Dim db3 As DBTypeEnum = My.Settings.dbtype
Select Case db3
Case DBTypeEnum.INFORMIX
System.Console.WriteLine("Informix")
Case DBTypeEnum.ORACLE
System.Console.WriteLine("Oracle")
Case DBTypeEnum.SQLSERVER
System.Console.WriteLine("SQL")
Case DBTypeEnum.SYBASE
System.Console.WriteLine("Sybase")
End Select
System.Console.ReadLine()
End Sub
End Module
3.
補充:
VB使用 My.Settings.dbtype
c#的方式為:
DbTypeEnum db = global::csmod02.Properties.Settings.Default.dbtype;