473,396 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

int to proc conversion

Hi,

I am using a conversion from int to char to use it with SNMP.
In this moment I use:

int proc=45; // here cam be any value from 1 to 255
string cProc="";
cProc+=Convert.ToChar(proc);
mib_write(computer,oid,new Universal(cProc));

but the problem is when I use proc value between 127 to 159, the cProc
values are all the same -> ""

I changed to:

[StructLayout(LayoutKind.Explicit)]
struct IntToCharCast
{
[FieldOffset(0)]
public int i;
[FieldOffset(0)]
public char f;
};
IntToCharCast caster;

int iProc=45;// here cam be any value from 1 to 255
char cProc;
caster.i = iProc;
cProc=caster.f;
mib_write(computer,oid,new Universal(cProc));

and I get the same values.

What I am doing wrong ?

Thank you,
Dan

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #1
2 1330
Dan,

Have you considered using one of the encodings to convert the value?

Also, are you sure your structure should have a char value in it?
Unless you are using unicode characters (possible, but I don't see many
implementations with functions exported from DLLs that take the time to use
unicode).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dan Pavel" <my**************@yahoo.com> wrote in message
news:uW**************@TK2MSFTNGP10.phx.gbl...
Hi,

I am using a conversion from int to char to use it with SNMP.
In this moment I use:

int proc=45; // here cam be any value from 1 to 255
string cProc="";
cProc+=Convert.ToChar(proc);
mib_write(computer,oid,new Universal(cProc));

but the problem is when I use proc value between 127 to 159, the cProc
values are all the same -> ""

I changed to:

[StructLayout(LayoutKind.Explicit)]
struct IntToCharCast
{
[FieldOffset(0)]
public int i;
[FieldOffset(0)]
public char f;
};
IntToCharCast caster;

int iProc=45;// here cam be any value from 1 to 255
char cProc;
caster.i = iProc;
cProc=caster.f;
mib_write(computer,oid,new Universal(cProc));

and I get the same values.

What I am doing wrong ?

Thank you,
Dan

*** Sent via Developersdex http://www.developersdex.com ***

Nov 17 '05 #2
Dan Pavel <my**************@yahoo.com> wrote:
I am using a conversion from int to char to use it with SNMP.
In this moment I use:

int proc=45; // here cam be any value from 1 to 255
string cProc="";
cProc+=Convert.ToChar(proc);
mib_write(computer,oid,new Universal(cProc));

but the problem is when I use proc value between 127 to 159, the cProc
values are all the same -> ""


I very much doubt that they're actually the same - they're *different*
unprintable characters. This is correct, as Unicode 128-159 are indeed
unprintable. What did you expect to see?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #3

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

Similar topics

3
by: Bob | last post by:
I'm currently updating one of our web sites and have encountered a strange problem. The page that is giving me the problem is written in ASP and hits a SQL 2K DB. When I click submit I have 4...
3
by: KathyB | last post by:
I'm trying to concatenate fields in SQL stored proc for use in text field in asp.net dropdownlist. I'm running into a problem when I try to use a DateTime field, but can't find the answer (so far)...
4
by: helmut woess | last post by:
Hello, i want to use the result set from a stored proc in another stored proc, for example: create stored procedure proc1 (@x int) as declare @tbl (y1 int, y2 int) insert into @tbl values(@...
4
by: Jean-Marc Blaise | last post by:
Dear all, I have simulated the windows MULTI application with a java program calling the SQLTP1DL proc referenced as DB2DARI application, on Linux Intel or ZLinux. If the proc is NOT FENCED,...
0
by: Dave Sisk | last post by:
I've created a system or external trigger on an AS/400 file a.k.a DB2 table. (Note this is an external trigger defined with the ADDPFTRG CL command, not a SQL trigger defined with the CREATE...
8
by: CSDunn | last post by:
Hello, I have a situation in which I need to address three SQL Server 2000 Stored Procedure parameters in the OnClick event of an Option Group. The Option Group lives on an Access 2000 ADP form. ...
14
by: aaron kempf | last post by:
I find that ADP does not support any Stored Procedures that use the 'CREATE PROC spHAPPY' syntax. CREATE PROC syntax is listed in books online. This syntax should be supported Here is a...
14
by: Roy | last post by:
Apologies for the cross-post, but this truly is a two-sided question. Given the option of creating Looping statements within a stored proc of sql server or in the code-behind of an .net webpage,...
10
by: Eric E | last post by:
Hi all, I am using an Access client linked to a PG 7.4 server via ODBC. I have a stored proc on the server that inserts rows into a table.particular table, accomplished via an INSERT within the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.