C# 字符串类型转换

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)
    {
    ... ...
    }
  }
}

//Threading
using 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 为 int
i = (int)d;
Console.WriteLine(i);
Thread.Sleep(1000);
Console.WriteLine();

//输出结果:5673

Nothing is impossible, if you set your mind to it !
原文地址:https://www.cnblogs.com/penny1141/p/4403411.html