您的位置:首页 > 编程语言 > C#

【C#笔札】1 string类型

2015-12-28 15:41 295 查看
C中没有string这个类型,而是用字符串数组来实现,相对来说比较麻烦。

LABVIEW相对来说要简单太多,毕竟他主要的精力集中在硬件控制上,软件操作方面极其简单。

C#类似,C#中有System.String这个类型。

今天还是用仿照着labview来学习C#.



1>String.length



length 是string的一个属性节点所以实现起来比较简单

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

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
String a = "Hello";
int alength = a.Length;
Console.WriteLine("The length of string a is {0}", alength);
Console.ReadLine();
return;
}
}
}


显示结果如下



2》Concatenate strings



C#实现起来相当简单直接二者相加即可。

3》String Subset



Substring()是C#中string的方法节点,使用起来也非常的方便。

如下 string c;

string d = c.Substring(”index“,”length“);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: