首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

关于C#字符串定义?该如何解决

2012-05-27 
关于C#字符串定义?有段代码因为是用VB编写的,我想转成C#。发现dim strdata as stringspace(1024)这条语话

关于C#字符串定义?
有段代码因为是用VB编写的,我想转成C#。发现dim strdata as string=space(1024)这条语话在C#中是没有space方法的,哪位大神可以给解答或者给个例子参考一下不胜感激。
Public Function Read(ByVal SectionName As String, ByVal KeyName As String) As String
  Dim intRetVal As Int32
  Dim strData As String = Space(1024)
  Try
  intRetVal = GetPrivateProfileString(SectionName, KeyName, Nothing, strData, strData.Length, _INIFileName)
  If intRetVal > 0 Then
  Read = strData.Substring(0, intRetVal)
  Else
  Read = ""
  End If
  Catch
  Read = ""
  End Try
  End Function

如果没明白意思,上面这个VB代码用C#该怎样写。

分不多在此谢谢各位了 



[解决办法]
String s = new String(' ', 1024);

热点排行