C#有关 字符串方法的使用
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#有关 字符串方法的使用的更多相关文章
- C#中对象,字符串,dataTable、DataReader、DataSet,对象集合转换成Json字符串方法。
C#中对象,字符串,dataTable.DataReader.DataSet,对象集合转换成Json字符串方法. public class ConvertJson { #region 私有方法 /// ...
- js字符串方法
字符串方法根据下标返回字符:str.charAt()//传入一个下标返回字符str.charCodeAt();// 传入一个下标获取编码String.formCharCode();//接受编码,编码转 ...
- python字符串方法的简单使用
学习python字符串方法的使用,对书中列举的每种方法都做一个试用,将结果记录,方便以后查询. (1) s.capitalize() ;功能:返回字符串的的副本,并将首字母大写.使用如下: >& ...
- 常用js字符串方法学习总结
2016-06-15 js数组和字符串方法有很多,并且有一部分在使用的过程中有很多方法是很容易被混淆的,今天来总结一下js中数组和字符串的方法. ♦数组(Array)的方法 1.push() 和 po ...
- Python 字符串方法详解
Python 字符串方法详解 本文最初发表于赖勇浩(恋花蝶)的博客(http://blog.csdn.net/lanphaday),如蒙转载,敬请保留全文完整,切勿去除本声明和作者信息. ...
- 千万别把js的正则表达式方法和字符串方法搞混淆了
我们在字符串操作过程中肯定经常用了test() split() replace() match() indexof()等方法,很多人经常把用法写错了,包括我,所以今天细细的整理了下. test()是判 ...
- T-SQL切割字符串方法小结
T-SQL切割字符串方法小结,只有表值函数那个是自己的思想,其它都是来源于网络的思想,请大家不要笑话,嘻嘻~网上大牛太多,这点东西虽然上不了台面,但是也算是自己的一个学习吧,能够对一个人有用也行.再不 ...
- js中字符串方法
字符串方法: 1. charAt(索引值)//通过索引值获取字符串中对应的值 例如: var str='sdf123'; alert(str.charAt(0));//结果弹出第一个索引对应的值:s
- JS字符串方法总结整理
//javascript字符串方法总结 1.String.charAt(n) //取得字符串中的第n个字符 2.String.charCodeAt(n) //取得字符串中第n个字符 ...
- javascript 字符串方法传参
javascript 字符串方法传参由于嵌套的单引号,双引号过多.有点混乱.. 正确方法如下: ' <td align="left"><input type= ...
随机推荐
- C#/PHP Compatible Encryption (AES256) ZZ
Finding a way to encrypt messages in C# and decrypting them in PHP or vice versa seems to be a " ...
- HDOJ --- 2151 Worm
Worm Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- HDU 2546 饭卡
http://acm.hdu.edu.cn/showproblem.php?pid=2546 呆呆. 饭卡 Time Limit: 5000/1000 MS (Java/Others) Memo ...
- POJ 3074 Sudoku (Dacing Links)
推荐一个写数独很好的博客:http://www.cnblogs.com/grenet/p/3163550.html 主要是把九宫格里的元素换到矩阵里面再求解dancing links 网上找的一模版 ...
- HOST1PLUS 的 VPS 主機-絕佳的性能和特惠的價格
HOST1PLUS 的 VPS 主機-絕佳的性能和特惠的價格 undefined Open Container Project undefined 80后美女董事长吴艳:嫁得好不一定比干得好容易 - ...
- Yii框架zii.widgets.grid自定义按钮,ajax触发事件并提示
相关类手册: http://www.yiichina.com/api/CButtonColumn buttons 属性 public array $buttons; the configurati ...
- hdoj 1150 Machine Schedule【匈牙利算法+最小顶点覆盖】
Machine Schedule Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- having的用法以及与where区别介绍
having子句可以让我们筛选成组后的各种数据,having子句在查询过程中慢于聚合语句,接下来通过实例介绍下,感兴趣的你可以参考下,希望可以帮助到你 having的用法 having子句可以让我们筛 ...
- web开发性能优化---扩展性能篇
1.实现代码分离 一个成熟的软件开发团队一般都不会全然手写代码.这里讲的代码分离仅仅要是开发中用到的小技巧,通过底层框架+手工代码方式结合实现高速开发和高速扩展. Code目录内文件不同意改动,目录主 ...
- ViewPager的用法和实现过程
看图先: 页面中填充内容是随机关键词飞入和飞出动画效果,随后会更新,如今请先无视吧 首先是 导入jar包 下载地址:android-support-v4.jar 布局文件中加入v ...