找到 34423 篇文章 关于编程
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)) ... 阅读更多
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() { ... 阅读更多
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 是否等于 ... 阅读更多
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 ... 阅读更多
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); ... 阅读更多
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()); ... 阅读更多
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 ... 阅读更多
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 ... 阅读更多
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)); } }输出这将产生以下 ... 阅读更多
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++) ... 阅读更多
数据结构
网络
关系数据库管理系统 (RDBMS)
操作系统
Java
iOS
HTML
CSS
Android
Python
C语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP