码迷,mamicode.com
首页 > Windows程序 > 详细

学习C#中一些简单的方法使用

时间:2017-08-02 15:35:13      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:简单   write   oid   void   sharp   names   key   namespace   ace   

indexof(‘字符or字串’)查找字串中指定字符或字串首次出现的地方,并返回起索引;

Substring(int index ,int length)

index:开始的长度初始从0;

length:要截取的子字符串的长度;

using System;

namespace Sharp
{
    class Program
    {
        public static void Main(string[] args)
        {
            string mystring="Hello World";
            string subtring1=mystring.Substring(0);
            string subtring2=mystring.Substring(0,5);
            
            Console.WriteLine(subtring1);
            Console.WriteLine(subtring2);
            
            Console.ReadKey();
        }
    }
}

技术分享

 Tostring(对象类名):把对象类名作为一个字符串返回;

 静态字段必须通过定义它的类来访问,不能用类的实例来访问

学习C#中一些简单的方法使用

标签:简单   write   oid   void   sharp   names   key   namespace   ace   

原文地址:http://www.cnblogs.com/UnityLittleBird/p/7246389.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!