C#、Java、JavaScript各自的字符串比较差异

JAVA 

String s = "RegionID"; String s1 = "gionID"; String s2 = s.substring(2); // "gionID" s1 == "gionID"; //true s1 == s2; //false s2 == "gionID"; //false s1 == "gionID"; //true //字符内容比较最好用:equals方法。

C# 字符串比较

string s = "RegionID";
string s1 = "gionID"; 
string s2 = s.substring(2); // "gionID"

s1 == "gionID";  //true
s1 == s2;           //true
s2 == "gionID";  //true
s1 == "gionID";  //true

JavaScript 字符串比较

var s = "test";
var s1 = "test"; 
var s2 = new Object("est"); 
s=="test";                   //true
s.substring(1)==s2;    //true
s.substring(1)===s2;  //false

//内容比较用“==”, 内容及内存地址同时比较用"===" 

 

posted @ 2012-12-01 18:51  csdnbbs  阅读(237)  评论(0编辑  收藏  举报