字符串string学习

要引用System

using System;

给一个字符串赋值

1.string a;

  a="12345";

string a="123456";

2.转换到大写

a.ToUpper();

3转换为小写

a.ToLower();

3取某字符串中间的从某处到某处的子字符串(与VB的不同,是从0开始的)

a.Substring(0, 2);从第一个开始取两个字符

4取字符串里面的某个字符的位置,如果没有返回0;

int b = a.IndexOf('1');

5.静态方法

 ForMat,格式化字符串

lbl.Text = string.Format("{0}:{1}({2}:{3})", DataBinder.Eval(e.Row.DataItem, "HGoals"),
                                           DataBinder.Eval(e.Row.DataItem, "AGoals"), DataBinder.Eval(e.Row.DataItem, "HGoals_half"),
                                           DataBinder.Eval(e.Row.DataItem, "AGoals_half"));

6.Split的使用,返回一个字符数组

string a = "2|3|4|5";
           string[] a_arr = a.Split('|');

7取得字符串数组的长度,从0开始

 a.GetLength(0);

8取得一个字符串的长度

string a = "1234";
        a.Length;

9.字符串数组的定义和赋值

string[] str_Pass_canshus = new string[3];
            string[] str_Pass_canshuvalues = new string[3];
            str_Pass_canshus[0] = "@MatchID";
            str_Pass_canshus[1] = "@Act";
            str_Pass_canshus[2] = "@result";

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值