C# 字符串类型转换

it2022-07-06  121

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Threading;

namespace CTest{   class Program   {     static void Main(string[] args)     {     ... ...     }   }}

 

//Threadingusing System.Threading; Thread.Sleep(1000);

//Value types Console.WriteLine("Size of int:{0}", sizeof(int); Console.WriteLine();

//输出结果:4

//字符串(String)类型的值可以通过两种形式进行分配:引号和 @引号string str ="CTest.cc"; @"CTest.cc";

//C# string 字符串的前面可以加 @(称作"逐字字符串")将转义字符(\)当作普通字符对待string str = @"C:\Windows"; string str = "C:\\Windows";

 

//C#类型转换 - 显示类型转换double d = 5673.25; int i; //强制转换 double 为 inti = (int)d; Console.WriteLine(i); Thread.Sleep(1000); Console.WriteLine();

//输出结果:5673

转载于:https://www.cnblogs.com/penny1141/p/4403411.html

相关资源:C#实现实体类与字符串互相转换的方法

最新回复(0)