VB.Net学习笔记(面向对象的基本数据类型)

类别:.NET开发 点击:0 评论:0 推荐:

这些基本类型也象类一样拥有各自的方法和属性,熟练运用它们能让你的程序更优雅和更有面向对象的味道。

 

基本类型的重要方法和属性举例

        Dim i As Int32

        Dim s As String

        Dim ss() As String

        Dim by As Byte

        Dim d As Double

        Dim b As Boolean

        Dim da As Date

        Dim c As Char

        Dim cc() As Char

 

        '整数操作

        i = Int32.Parse("123", Globalization.NumberStyles.AllowCurrencySymbol) '123

        i = Int32.MaxValue '2147483647

        i = Int32.MinValue '-2147483648

        by = Byte.Parse("1") '1

        '浮点数操作

        d = Double.PositiveInfinity '正无穷大

        d = Double.Epsilon '4.94065645841247E-324

        '布尔操作

        s = Boolean.TrueString 'True

        '日期操作

        da = Date.MaxValue '9999-12-31 23:59:59

        da = Date.MinValue '0:00:00

        da = Date.Now '2004-5-7 13:17:35

        b = Date.IsLeapYear(2004) 'True

        i = Date.DaysInMonth(2004, 5) '31

        '以下方法用于判断字符的特性

        Char.IsControl(c)

        Char.IsDigit(c)

        Char.IsLetter(c)

        Char.IsLetterOrDigit(c)

        Char.IsLower(c)

        Char.IsNumber(c)

        Char.IsPunctuation(c)

        Char.IsSeparator(c)

        Char.IsSurrogate(c)

        Char.IsSymbol(c)

        Char.IsWhiteSpace(c)

        Char.IsUpper(c)

        'Char转换

        Char.ToLower(c)

        Char.ToUpper(c)

        '字符串操作

        cc = s.ToCharArray()

        ss = s.Split(",")

        s = s.Substring(5, 3)

        s = s.Trim()

 

 

 

本文地址:http://com.8s8s.com/it/it44756.htm