473,804 Members | 2,265 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I convert char to int (Int32) in multidimensiona l array?



Hi Everybody,

I am new to VC.NET and I need your help.

I would like the array to print characters as '.'s (dots) instead of 0s as
in (see below in front of //------>>>>>.

I tried to use casting like this:

multArray2[m,n] = int ('.');

If these are confusing. My question is how to use multidimensiona l array to
print characters instead of int

//Declare loop counters

int m,n,o;

//Create multidimensiona l array of int32s

Int32 multArray2[,] = new Int32[6,7];

//Fill the array with value

for (m=0; m<multArray2->GetLength(0) ; m++)

for (n=0; n<multArray2->GetLength(1) ; n++)

{

//--------->>>>> multArray2[m,n] = 0 ;

}

Thanks.
Feb 24 '06 #1
2 1688
I would like the array to print characters as '.'s (dots) instead of 0s as
in (see below in front of //------>>>>>.


Int32 val = '.';
Console.WriteLi ne(Convert::ToC har(val));

this will print a '.'
val is an integer that will receive the decimal ASCII value of the '.'
character which is 46.
If you would not convert to char, the value 46 would be printed, since that
is the default value to string conversion for an Int32.

you can simply initialize each value in your matrix to '.' and when you want
to print it you use a comniation of Write and WriteLine to print your matrix
to the screen.

be aware that converting 12345678 to Char will not work, since characters
are limited to 8 bits.

--

Kind regards,
Bruno.
br************* *********@hotma il.com
Remove only "_nos_pam"
Feb 24 '06 #2
Thanks Bruno,
I will try it and let you know.
"Bruno van Dooren" <br************ **********@hotm ail.com> wrote in message
news:52******** *************** ***********@mic rosoft.com...
I would like the array to print characters as '.'s (dots) instead of 0s
as
in (see below in front of //------>>>>>.


Int32 val = '.';
Console.WriteLi ne(Convert::ToC har(val));

this will print a '.'
val is an integer that will receive the decimal ASCII value of the '.'
character which is 46.
If you would not convert to char, the value 46 would be printed, since
that
is the default value to string conversion for an Int32.

you can simply initialize each value in your matrix to '.' and when you
want
to print it you use a comniation of Write and WriteLine to print your
matrix
to the screen.

be aware that converting 12345678 to Char will not work, since characters
are limited to 8 bits.

--

Kind regards,
Bruno.
br************* *********@hotma il.com
Remove only "_nos_pam"

Feb 26 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5663
by: phancey | last post by:
I am trying to invoke a web service method dynamically. I have created a generic function that takes a method name, string of parameters and calls the web method using System.Reflection: MethodInfo mi = proxyInstance.GetType().GetMethod(methodName); object paramsArray = (object)methodParams.ToArray(typeof(object)); object result = mi.Invoke(proxyInstance, paramsArray); where methodParams is an array of parameters where the value...
19
4164
by: jeff | last post by:
how do you convert form byte to Int32 while retaining the binary value of the byte array
4
4720
by: Ping | last post by:
Hi, All, We can use BitConverter.ToString(byte) to a string, but how to get the byte from a string like "AD-A6-0D-1F"?
14
7976
by: Me | last post by:
Hi all I am getting a really bizzare error on when I convert a string into a datetime: The code is : DateTime dt1 = Convert.ToDateTime("10 Sep 2005"); Console.WriteLine(dt1.Year);
8
6674
by: mesutalturk | last post by:
How do i convert the following C# code to Delphi? public static uint GenerateSiteID(string SiteName) { uint id = 0; char arr = SiteName.ToCharArray(); //Convert the sitename to a Char Array for (int i = 0; i < arr.Length; i++) {
2
22615
by: Potiuper | last post by:
Question: Is it possible to use a char pointer array ( char *<name> ) to read an array of strings from a file in C? Given: code is written in ANSI C; I know the exact nature of the strings to be read (the file will be written by only this program); file can be either in text or binary (preferably binary as the files may be read repeatedly); the amount and size of strings in the array won't be known until run time (in the example I have it in...
5
10358
by: TS | last post by:
is there some code somewhere that does this? i have a jagged array that is not jagged, it has an equal number of rows and columns in each array so it should convert but want to get the code to do it somewhere. thanks
5
3803
by: =?Utf-8?B?QXlrdXQgRXJnaW4=?= | last post by:
Hi Willy, Thank you very much for your work. C++ code doesnot make any serialization. So at runtime C# code gives an serialization error at "msg_file_s sa = (msg_file_s) bf.Deserialize(ms);" I thought that it is very hard to memory map structure array. I need both read and write memory mapped file at both side of C# and C++.
16
1655
by: MN | last post by:
I have a question : How to understand the mean of char** type ?
0
9714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10599
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10347
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10090
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7635
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6863
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4308
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3832
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.