找到 34423 篇文章 关于编程

C# 中的 StringBuilder.Chars[] 属性

AmitDiwan
更新于 2019-12-03 12:49:09

80 次浏览

StringBuilder.Chars[] 属性获取或设置此实例中指定字符位置处的字符。语法语法如下:public char this[int index] { get; set; }上面,index 参数是字符的位置。示例让我们现在来看一个例子 - 实时演示using System; using System.Text; public class Demo {    public static void Main() {       StringBuilder strBuilder = new StringBuilder("ghgh78hkjj");       int num = 0;       for (int i = 0; i < strBuilder.Length; i++) {          char c = strBuilder[i];          if (Char.IsDigit(c))   ... 阅读更多

C# 中的 Thread.CurrentThread 属性

AmitDiwan
更新于 2019-12-03 12:45:33

199 次浏览

C# 中的 Thread.CurrentThread 属性用于获取当前正在运行的线程。语法语法如下:public static System.Threading.Thread CurrentThread { get; }示例让我们现在来看一个例子 - 实时演示using System; using System.Threading; public class Demo {    public static void Main() {       Thread thread = new Thread(new ThreadStart(demo1));       ThreadPool.QueueUserWorkItem(new WaitCallback(demo2));       thread = Thread.CurrentThread;       thread.Name ="Demo Thread";       Console.WriteLine("当前正在运行的线程 = "+thread.Name);       Console.WriteLine("线程的当前状态 = "+thread.ThreadState);       Console.WriteLine("ManagedThreadId = "+thread.ManagedThreadId);    }    public static void demo1() { ... 阅读更多

C# 字符串属性

AmitDiwan
更新于 2019-12-03 12:40:51

764 次浏览

以下是 C# 中 String 类的属性:序号属性和描述1Chars获取当前 String 对象中指定位置处的 Char 对象。2Length获取当前 String 对象中的字符数。示例让我们来看一个例子 - 实时演示using System; public class Demo {    public static void Main() {       string str1 = "h8b9";       string str2 = "abcdef";       Console.WriteLine("字符串1 是否为空或为空白? = "+string.IsNullOrEmpty(str1));       Console.WriteLine("字符串2 是否为空或为空白? = "+string.IsNullOrEmpty(str2));       bool val = str1 != str2;       Console.WriteLine("str1 是否等于 ... 阅读更多

C# Substring() 方法

AmitDiwan
更新于 2019-12-03 12:34:31

4K+ 次浏览

C# 中的 Substring() 方法用于从此实例中检索子字符串。子字符串从指定的字符位置开始,一直持续到字符串的末尾。语法语法如下:public string Substring (int begnIndex); public string Substring (int begnIndex, int len);上面,begnIndex 是此实例中子字符串的基于零的起始字符位置。len 参数是要检索的子字符串的长度示例让我们现在来看一个例子 - 实时演示using System; public class Demo {    public static void Main(String[] args) {       string str1 = "Katherine";       string ... 阅读更多

C# String.ToUpperInvariant 方法

AmitDiwan
更新于 2019-12-03 12:31:04

872 次浏览

C# 中的 String.ToUpperInvariant() 方法用于返回使用不变文化的区分大小写规则转换为大写的此 String 对象的副本。语法语法如下:public string ToUpperInvariant ();示例让我们现在来看一个例子 - 实时演示using System; using System.Text; public class Demo {    public static void Main(String[] args) {       string str1 = "one";       string str2 = "TWO";       string str3 = "ThrEE";       Console.WriteLine("字符串 1 = "+str1);       Console.WriteLine("字符串1 ToUpperInvariant = "+str1.ToUpperInvariant());       Console.WriteLine("字符串 2 = "+str2);       ... 阅读更多

C# String.ToLowerInvariant 方法

AmitDiwan
更新于 2019-12-03 12:18:20

891 次浏览

C# 中的 String.ToLowerInvariant() 方法用于返回使用不变文化的区分大小写规则转换为小写的此 String 对象的副本。语法语法如下:public string ToLowerInvariant ();示例让我们现在来看一个例子 - 实时演示using System; using System.Text; public class Demo {    public static void Main(String[] args) {       string str1 = "Pink Floyd";       string str2 = "Ariana";       Console.WriteLine("字符串 1 = "+str1);       Console.WriteLine("字符串1 ToLowerInvariant = "+str1.ToLowerInvariant());       Console.WriteLine("字符串 2 = "+str2);       Console.WriteLine("字符串2 ToLowerInvariant = "+str2.ToLowerInvariant());     ... 阅读更多

C# 中的 TimeSpan.FromTicks() 方法

AmitDiwan
更新于 2019-12-03 12:14:14

303 次浏览

C# 中的 TimeSpan.FromTicks() 方法用于返回表示指定时间的 TimeSpan,其中规范以刻度为单位。语法语法如下:public static TimeSpan FromTicks (long val);上面,参数 val 是表示时间的刻度数。示例让我们现在来看一个例子 - 实时演示using System; public class Demo {    public static void Main() {       TimeSpan span1 = TimeSpan.FromTicks(18768768);       TimeSpan span2 = new TimeSpan(-9, 45, 50);       TimeSpan span3 = TimeSpan.FromHours(5);       TimeSpan span4 = TimeSpan.FromMilliseconds(10000);       TimeSpan span5 ... 阅读更多

C# Object.GetHashCode() 方法及示例

AmitDiwan
更新于 2019-12-03 12:10:56

972 次浏览

C# 中的 Object.GetHashCode() 方法用作默认哈希函数。语法public virtual int GetHashCode ();示例让我们现在来看一个例子 - 实时演示using System; public class Demo {    public static void Main() {       Object ob = new Object();       String str = "Jim";       Type type1 = ob.GetType();       Type type2 = str.GetType();       Console.WriteLine("哈希码 = "+type1.GetHashCode());       Console.WriteLine("哈希码 = "+type2.GetHashCode());    } }输出哈希码 = 30015890 哈希码 = 21083178示例让我们现在再来看一个例子:using System; public struct Value {    private int v1;    private int ... 阅读更多

C# IsNullOrWhiteSpace() 方法

AmitDiwan
更新于 2019-12-03 12:06:56

220 次浏览

C# 中的 IsNullOrWhiteSpace() 方法用于指示指定的字符串是否为空、空或仅包含空白字符。语法public static bool IsNullOrWhiteSpace (string val);上面,参数 val 是要测试的字符串。让我们现在来看一个例子示例让我们现在来看一个例子:实时演示using System; public class Demo {    public static void Main() {       string str1 = null;       string str2 = String.Empty;       Console.WriteLine("字符串1 是否为空或为空白? = "+String.IsNullOrWhiteSpace(str1));       Console.WriteLine("字符串2 是否为空或为空白? = "+String.IsNullOrWhiteSpace(str2));    } }输出这将产生以下 ... 阅读更多

C# BitConverter.ToUInt16() 方法

AmitDiwan
更新于 2019-12-03 12:03:46

272 次浏览

C# 中的 BitConverter.ToUInt16() 方法用于返回从字节数组中指定位置的两个字节转换而来的 16 位无符号整数。语法public static ushort ToUInt16 (byte[] val, int begnIndex);上面,val 是字节数组,而 begnIndex 是 val 中的起始位置。示例让我们现在来看一个例子 - 实时演示using System; public class Demo {    public static void Main() {       byte[] arr = { 10, 20, 30, 40, 50};       int count = arr.Length;       Console.Write("字节数组... ");       for (int i = 0; i < count; i++) ... 阅读更多

广告

© . All rights reserved.