关于C#字符串定义?

Jerry_xujin 2012-05-23 07:49:36
有段代码因为是用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#该怎样写。

分不多在此谢谢各位了

...全文
71 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Jerry_xujin 2012-05-23
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
String s = new String(' ', 1024);
[/Quote]

谢谢,我试一下。
newxdlysk 2012-05-23
  • 打赏
  • 举报
回复
String s = new String(' ', 1024);

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧