Link to home
Start Free TrialLog in
Avatar of ube100
ube100Flag for United Kingdom of Great Britain and Northern Ireland

asked on

VB string function equivalent in c#...

How do i convert this vb code into c#

strTemp = String(255, Chr$(0))
Avatar of abel
abel
Flag of Netherlands image

Like this:

string strTemp = new string('\0', 255);
The '\0' part is the equivalent of the the Chr(0) function (ascii character NUL).

Btw, I assume you meant this as VB code, because the mentioned VB code will not compile (first parameter of constructor cannot be an Integer):

Dim strTemp As New String(Chr(0), 255)
Avatar of ube100

ASKER

next code is:

lRet = GetTempPath(255, strTemp)

API function for the GetTempPath is declared like this:

Private Declare Function GetTempPath Lib "Kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

How will I convert this into C#.
ASKER CERTIFIED SOLUTION
Avatar of abel
abel
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ube100

ASKER

thank very much sir for help!!!
You're welcome, glad it helped :)