| problem with passing values to char array |
| krishna k posted at Wednesday, March 01, 2006 3:28 AM |
hi every one,
here iam having the problem about charecter array.
In C Language he used pass the values as bellow
public unsafe struct x25data
{
char xd_data[];
int xd_len;
}
but here he is passing values as follows
x25data.xd_data[0]=0x42;
x25data.xd_data[1]=0x07;
x25data.xd_data[2]=0x07;
how can we pass the same values in C#.net.
can we pass them as he passed in c.
help me in this please. |
 |
|
|
| |
Array |
| Shallu Gupta replied at Wednesday, March 01, 2006 3:45 AM |
yeah you can do this..
see this example..
[CODE]
string [] test = new string[2];
test[0]= "first";
test[1]= "second";
[/CODE] |
 |
| |
| cannot convert string[] to char[] will occur know |
| Raja yashwanth Reddy Gunda replied at Wednesday, March 01, 2006 4:32 AM |
here this charecter array was defined in dll.
i want to use the dll in my application,for that the above i given that example.
can we that hexadecimal values as elements of an array. |
 |
| |
convert hexadecimal values to char |
| Pankaj Sharma replied at Wednesday, March 01, 2006 4:45 AM |
Hi,
Is it this you need?
[CODE]
public struct Test
{
public char[] arrTest;
public Test(int intLen)
{
arrTest= new char[intLen];
}
}
//Declaring a struct object
Test temp = new Test(2);
//converting it into char
temp.arrTest[0]= Convert.ToChar(0x42);
Console.WriteLine(temp.arrTest[0]);
//It displays B on console.
[/CODE] |
 |
| |
| convert hexadecimal values to char |
| Pankaj Sharma replied at Wednesday, March 01, 2006 4:48 AM |
Hi,
Is it this you need?
[CODE]
public struct Test
{
public char[] arrTest;
public Test(int intLen)
{
arrTest= new char[intLen];
}
}
//Declaring a struct object
Test temp = new Test(2);
//converting it into char
temp.arrTest[0]= Convert.ToChar(0x42);
//It displays B on console.
Console.WriteLine(temp.arrTest[0]);
[/CODE] |
 |
| |
| clarification on the values saved in the example |
| Raja yashwanth Reddy Gunda replied at Wednesday, March 01, 2006 5:04 AM |
with reference to your answer
in c the values which are saved are passed as hexadecimal values to the calling position( i.e to the x25 Protocol) does the same happen in c#
I think that char (0x47) i.e char 66 i.e B will be passed this doesnot solve my problem |
 |
| |
|
|