马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
一个很大的类库。应用程序之所以难以跨平台,在于直接调用了特定平台的接口,而一个巨大的类库,就能极大地减少应用程序对平台的依赖。字符串PublicClassuStringClassuString
PrivateSharedgEncodingAsSystem.Text.Encoding=System.Text.Encoding.GetEncoding("GB2312")
PublicSharedPropertyEncoding()PropertyEncoding()AsSystem.Text.Encoding
Get
ReturngEncoding
EndGet
Set(ByValvalueAsSystem.Text.Encoding)
gEncoding=value
EndSet
EndProperty
PublicSharedFunctionLength()FunctionLength(ByValsAsString)AsInteger
ReturngEncoding.GetByteCount(s)
EndFunction
PublicSharedFunctionPadLeft()FunctionPadLeft(ByValsAsString,ByValtotalWidthAsInteger,ByValpaddingCharAsChar)AsString
Returns.PadLeft(totalWidth+s.Length-Length(s),paddingChar)
EndFunction
PublicSharedFunctionPadLeft()FunctionPadLeft(ByValsAsString,ByValtotalWidthAsInteger)AsString
Returns.PadLeft(totalWidth+s.Length-Length(s))
EndFunction
PublicSharedFunctionPadRight()FunctionPadRight(ByValsAsString,ByValtotalWidthAsInteger,ByValpaddingCharAsChar)AsString
Returns.PadRight(totalWidth+s.Length-Length(s),paddingChar)
EndFunction
PublicSharedFunctionPadRight()FunctionPadRight(ByValsAsString,ByValtotalWidthAsInteger)AsString
Returns.PadRight(totalWidth+s.Length-Length(s))
EndFunction
PublicSharedFunctionSubString()FunctionSubString(ByValLineAsString,ByValIndexAsInteger,ByValLengthAsInteger)AsString
ReturngEncoding.GetString(gEncoding.GetBytes(Line),Index,Length)
EndFunction
EndClass
测试对照:
PrivateSubToolStripButton6_Click()SubToolStripButton6_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesToolStripButton6.Click
DimtmpAsString="中国China"
Console.WriteLine(LzmTW.uString.Encoding.EncodingName)
Console.WriteLine(LzmTW.uString.Length(tmp))
Console.WriteLine(tmp.Length)
Console.WriteLine(tmp.Substring(0,2))
Console.WriteLine(LzmTW.uString.SubString(tmp,0,2))
Console.WriteLine(NewString("*"c,20))
Console.WriteLine(LzmTW.uString.PadLeft(tmp,20,"*"c))
Console.WriteLine(tmp.PadLeft(20,"*"c))
Console.WriteLine(LzmTW.uString.PadRight(tmp,20,"*"c))
Console.WriteLine(tmp.PadRight(20,"*"c))
Console.WriteLine(LzmTW.uString.PadLeft(tmp,20))
Console.WriteLine(tmp.PadLeft(20))
Console.WriteLine(LzmTW.uString.PadRight(tmp,20))
Console.WriteLine(tmp.PadRight(20))
EndSub
它有很多缺点的,有兴趣可以到网上去搜索一下。于是微软有发明了“下一代”C++:C++/CLI语言,这个可以解决在.NETFramework中,托管C++产生的问题。在《程序员》杂志上,lippman和李建中合作连载介绍了C++/CLI语言。 |