C# .NET - problem with passing values to char array

Asked By krishna k
01-Mar-06 03: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  Array

01-Mar-06 03: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  cannot convert string[] to char[] will occur know

01-Mar-06 04: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  convert hexadecimal values to char

01-Mar-06 04: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  convert hexadecimal values to char
01-Mar-06 04: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  clarification on the values saved in the example
01-Mar-06 05: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
Create New Account
help
you get records number from 5 to 15 in a dataset of 100 records? Write code. Answer1 DataSet ds1 = new DataSet(); String strCon = ”data source = IBM-6BC8A0DACEF;initial catalog = pubs;integrated security = SSPI;persist” +” security info = False user id = sa;workstation id = IBM-6BC8A0DACEF;packet size = 4096?; String strCom1 = ”SELECT * FROM employee”; SqlDataAdapter sqlDa1 = new SqlDataAdapter(strCom1, strCon); ds1.Tables.Add(”employee”); sqlDa1 Stored Procedure in.NET? Give an example. Answer1 ds1 = new DataSet(); sqlCon1 = new SqlConnection(connectionstring); String strCom1 = ”byroyalty”; sqlCom1 = new SqlCommand(strCom1, sqlCon1); sqlCom1.CommandType = CommandType.StoredProcedure; sqlDa1 = new SqlDataAdapter(sqlCom1 maximum length of a varchar in SQL Server? Answer1 VARCHAR[(n)] Null-terminated Unicode character string of length n, with a maximum of 255 characters. If n is not supplied, then 8000 Answer3 The business logic is the aspx.cs or the aspx.vb where the code is being written. The presentation logic is done with .aspx extention. How do you define Microsoft-provided calendar control, how do you develop it? Do you copy and paste the code into each and every page of your application? Create the Calendar User Control The control returns the complete(absolute) path of the file used in parameter. Answer3 It returns a string containing the physical path in the server’s file system that corresponds to the virtual
is CTS? (B)What is a CLS (Common Language Specification)? (B)What is a Managed Code? (B)What is a Assembly? (A) What are the different types of Assembly? (B) What C#? (I) what is the difference between System exceptions and Application exceptions? (I)What is CODE Access security? (I)What is a satellite assembly? (A) How to prevent my .NET DLL in .NET? (B) When we use windows API in .NET is it managed or unmanaged code? (I)What is COM? (A) What is Reference counting in COM? (A) Can you describe What are dependencies in cache and types of dependencies? (A)Can you show a simple code showing file dependency in cache? (A) What is Cache Callback in Cache? (A) What is Hidden frames? (I) What are benefits and limitations of using Cookies? (I) What is Query String and What are benefits and limitations of using Query Strings? (I) What is Absolute and What is nested Classes? (B)What is Operator overloading in .NET? (I) For the below code which constructor will fire first? (B)What is the significance of Finalize method in .NET C#? (A)Can two catch blocks be executed? (A) What is the difference between System.String and System.StringBuilder classes? Chapter 7: ASP.NET (B) What’ is the sequence in which If client side validation is enabled in your Web page, does that mean server side code is not run. (A)Which JavaScript file is referenced for validating the validators at the
cut out is): * ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** * using System; using System.IO; namespace FtsData { [Serializable] public class StringType { private string first = ""; / / original data private string data = ""; / / current data private bool nullFirst = false; / / original Data null private bool nullData = false; / / current data null private bool changed = false; public StringType() { } public StringType(string initial) { first = initial; data = initial; } public bool IsNull() { return nullData; } public bool IsFirstNull() { return nullFirst; } public void SetNull() { nullData = true; data = ""; } public void SetFirstNull() { nullFirst = true; first = ""; } / / Properties public string First { get { return first; } set { first = value; } } public string Data { get { return data; } set { data = value; nullData = false; changed = true;} } public bool Changed { get nullFirst; } public void SetNull() { nullData = true; _data = ""; } public void SetFirstNull() { nullFirst = true; _first = ""; } / / Properties public string First { get { return _first; } set { _first = value; } } public string Data { get { return _data; } set { _data = value; nullData = false; changed = true;} } public bool Changed { get return changed;} set {changed = value;} } } [Serializable] public class StringType : DataType { private string _first = ""; / / original data private string _data = ""; / / current data public StringType() { } public StringType(string initial) { _first
CQL by Patrick Smacchia Content • Introduction • Getting started • CQL Queries vs. CQL Constraints • CQL and code metrics • CQL and naming rules • CQL and the graph of dependencies • CQL and the graph http: / / www.NDepend.com ). It is a free .NET tool for developers which analyses IL code and produces reports containing numerous code metrics, warnings and diagrams. The 2.0 version provides great enhancements such as an interactive your application and a new language dedicated to query and constraint the structure of your code: Code Query Language ( CQL ). The purpose of this article is to expose some quantitative and qualitative analyse any .NET application (i.e any set of assemblies) no matter it is a console, windows form or ASP.NET application and no matter it is written with C# or help you know where you should focus your energy to enhance the quality of your code. For example you can use the following CQL query to know where your biggest methods Text.RegularExpressions.RegexCharClass. . cctor() .ctor() 2462 System.Text.RegularExpressions.RegexCharClass. . ctor() ImportAccessorMapping(MemberMapping, FieldModel, XmlAttributes, String, Type, Boolean, Boolean) 2344 System.Xml.Serialization.XmlReflectionImporter. ImportAccessorMapping(MemberMapping, FieldModel, XmlAttributes, String, Type, Boolean
do is read old legacy random access files. I used UDTs in vb6, where the string variables had various fixed lengths making up fields concatenated to records. Another thing I want but incredibly slow way) Module Module1 Structure FileRecord Public anInteger As Integer Public aString As String Public anotherString As String Public aSingle As Single End Structure Sub Main() ' create the randome access file Dim hFile FileRecord hFile = FreeFile() FileOpen(hFile, "testing.rnd", OpenMode.Random, OpenAccess.Read) FileGet(hFile, rec, 2) Console.WriteLine("*{0}*", rec.aString) End Sub End Module Personally, I would abandon this method. Like Explicit Public FBU As DataBlock1 . . .etc '- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Public Type DataBlock1 ' company master information (FBU) BusName As String * 30 Address1 As String * 30 Address2 As String * 30 Postcode As String * 6 Tel As String * 20 Fax As String * 20 Email As String * 30 RegForGST As