Microsoft documentation indicates that CharLowerBuffA is an ANSI version of this method, but you specify Unicode.
Try either using ANSI - specifying CharSet = CharSet.Ansi - or if you need Unicode, use CharLowerBuffW and CharUpperBuffW .
In addition, the method accepts two parameters. You do not have a second. So try the following:
[DllImport("User32.dll", EntryPoint = "CharLowerBuffW", ExactSpelling = false, CharSet = CharSet.Unicode, SetLastError = true )] public static extern string CharLower(string lpsz, int cchLength); [DllImport("User32.dll", EntryPoint = "CharUpperBuffW", ExactSpelling = false, CharSet = CharSet.Unicode, SetLastError = true )] public static extern string CharUpper(string lpsz, int cchLength);
And name it as follows:
string ChangeToLower = CharLower(l, l.Length);
If this still doesn't work, try using character arrays like NatarajC.
source share