using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
string Str1 = "download";
string Str2 = "DOWNLOAD";
string Str3 = String.Format("{0},{1}!!!",Str1,Str2);
DateTime dt = DateTime.Now;//获取系统当前日期
string Str4 = String.Format("{0:D}",dt);
string Str5 = String.Format("{0:M}", dt);
string Str6 = "";
Str6 = Str1.Substring(4,4);//截取字符串
A Str7 = new A();//实例化类A Console.WriteLine(string.Compare(Str1,Str2) );//比较字符串,判断大小,返回0;1;-1
Console.WriteLine(string.Compare(Str1,Str1));
Console.WriteLine(string.Compare(Str2,Str1));
Console.WriteLine(Str1.CompareTo(Str2));
Console.WriteLine(string.Equals(Str1,Str2));//比较字符串,判断两个字符串是否相等,返回true 或false
Console.WriteLine(Str1.Equals(Str1));
Console.WriteLine(Str3);
Console.WriteLine(Str4);
Console.WriteLine(dt);
Console.WriteLine(Str5);
Console.WriteLine(Str6);
Str7.my();//调用类A中的方法 Console .ReadKey();
}
}
class A//声明一个类
{
public void my()//声明一个方法
{
string StrA = "use^life#download,you"; //声明字符串StrA
char[] separator= { '^','#',','}; //声明分割字符数组
String[] splitstrings=new String[100];//声明一个字符串数组
splitstrings = StrA.Split(separator);//分割字符串
for (int i = 0; i < splitstrings.Length; i++)//splitstrings.Length等于4
{
Console.WriteLine("item{0}:{1}",i,splitstrings[i]); }
Console.ReadKey();
}
}
}

  

C#有关 字符串方法的使用的更多相关文章

  1. C#中对象,字符串,dataTable、DataReader、DataSet,对象集合转换成Json字符串方法。

    C#中对象,字符串,dataTable.DataReader.DataSet,对象集合转换成Json字符串方法. public class ConvertJson { #region 私有方法 /// ...

  2. js字符串方法

    字符串方法根据下标返回字符:str.charAt()//传入一个下标返回字符str.charCodeAt();// 传入一个下标获取编码String.formCharCode();//接受编码,编码转 ...

  3. python字符串方法的简单使用

    学习python字符串方法的使用,对书中列举的每种方法都做一个试用,将结果记录,方便以后查询. (1) s.capitalize() ;功能:返回字符串的的副本,并将首字母大写.使用如下: >& ...

  4. 常用js字符串方法学习总结

    2016-06-15 js数组和字符串方法有很多,并且有一部分在使用的过程中有很多方法是很容易被混淆的,今天来总结一下js中数组和字符串的方法. ♦数组(Array)的方法 1.push() 和 po ...

  5. Python 字符串方法详解

    Python 字符串方法详解 本文最初发表于赖勇浩(恋花蝶)的博客(http://blog.csdn.net/lanphaday),如蒙转载,敬请保留全文完整,切勿去除本声明和作者信息.        ...

  6. 千万别把js的正则表达式方法和字符串方法搞混淆了

    我们在字符串操作过程中肯定经常用了test() split() replace() match() indexof()等方法,很多人经常把用法写错了,包括我,所以今天细细的整理了下. test()是判 ...

  7. T-SQL切割字符串方法小结

    T-SQL切割字符串方法小结,只有表值函数那个是自己的思想,其它都是来源于网络的思想,请大家不要笑话,嘻嘻~网上大牛太多,这点东西虽然上不了台面,但是也算是自己的一个学习吧,能够对一个人有用也行.再不 ...

  8. js中字符串方法

    字符串方法: 1. charAt(索引值)//通过索引值获取字符串中对应的值 例如: var str='sdf123'; alert(str.charAt(0));//结果弹出第一个索引对应的值:s

  9. JS字符串方法总结整理

    //javascript字符串方法总结   1.String.charAt(n)      //取得字符串中的第n个字符   2.String.charCodeAt(n)  //取得字符串中第n个字符 ...

  10. javascript 字符串方法传参

    javascript 字符串方法传参由于嵌套的单引号,双引号过多.有点混乱.. 正确方法如下: '   <td align="left"><input type= ...

随机推荐

  1. Delphi TcxTreelist 表格左边总是缩进去 ,好像有偏移 解决方法

    1.  TcxTreelist的表格总是总是缩进去,如下效果 : 但是,新建一个没有偏移 ,经过观察,原来在  属性Images造成的,  把imgToolbars去除就可以了. 效果:

  2. 洛谷1377 M国王 (SCOI2005互不侵犯King)

    洛谷1377 M国王 (SCOI2005互不侵犯King) 本题地址:http://www.luogu.org/problem/show?pid=1377 题目描述 天天都是n皇后,多么无聊啊.我们来 ...

  3. opencv 1.0 与 2.0的库对应表

    libcvaux.so.2 -> /usr/lib/libopencv_video.so.2.2.0 libcv.so.2 -> /usr/lib/libopencv_legacy.so. ...

  4. Spark history-server 配置 !运维人员的强大工具

    spark  history Server产生背景 以standalone运行模式为例,在运行Spark Application的时候,Spark会提供一个WEBUI列出应用程序的运行时信息:但该WE ...

  5. windows mobile 6.5 隐藏 左下角(左上角)的开始按钮 叉号关闭按钮

    其实做起来很简单,但是国内的网站就是找不到. 1.开始按钮原来的界面是这样的: windows mobile 6.0界面: windows mobile 6.5.X界面: 修改一个windows mo ...

  6. 配置nginx如果获取不到图片 去另外一台服务器获取

    配置nginx服务器从一台服务器如果获取不到图片 从另外一台服务器中获取 location ^~ /uploads/ { root /data/weiwend/weiwang; try_files $ ...

  7. action使用大全

    1.Intent的用法: (1)Action跳转 1. 使用Action跳转,当程序AndroidManifest.xml中某一个 Activity的IntentFilter定义了包含Action, ...

  8. EPPlus与Excel完美的结合

    本文转载:http://www.cnblogs.com/olartan/archive/2012/07/14/2591711.html 笔者近期在公司项目中需要生产比较复杂的Excel报表, 问题点是 ...

  9. 在 VS14 上安装 Visual F# Power Tools

    在 VS14 上安装 Visual F# Power Tools Visual F# Power Tools 眼下版本号 1.3,下载地址:http://visualstudiogallery.msd ...

  10. [Javascript + rxjs] Simple drag and drop with Observables

    Armed with the map and concatAll functions, we can create fairly complex interactions in a simple wa ...