By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,702 Members | 1,771 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,702 IT Pros & Developers. It's quick & easy.

operation result int string

P: n/a
Hi everybody,

¿can help me?,

I'm novice in C#,

can tell me what type of variable gives this operation.

Dim a As UInteger = 63689

Dim stringA As String = "w"

result = a + stringA
Thanks everybody
Sep 26 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
On Sep 26, 4:17 am, "MoRpHeOo" <morph...@gmail.comwrote:
Hi everybody,

¿can help me?,

I'm novice in C#,

can tell me what type of variable gives this operation.

Dim a As UInteger = 63689

Dim stringA As String = "w"

result = a + stringA

Thanks everybody
The variable type would probably be "InvalidCastException" as you are
performing an illegal call. It also seems that you have both Option
Explicit and Option Strict turned off. These should be turned on
almost 99.99% of the time.

Perhaps you are wanting to use the "+" operator for string
concatenation (which is the "&" operator in VB)? Then you could do
this:

Dim result As String = a.ToString() & stringA

If thats not what you were looking for, why not share what you are
trying to accomplish?

Thanks,

Seth Rowe

Sep 26 '07 #2

P: n/a
Thanks Seth Rowe,

I don't wanna to concatenation the variable.

The entire function:

Dim a As UInteger = 63689
Dim b as UInteger = 568978
Dim result as UInteger = 0
Dim stringA As String = "WORK"

For i as Integer = 0 to 3
result = result * a + stringA(i)
a = a *b
Next

result = result and 2158975

Thanks, is so complex...

"rowe_newsgroups" <ro********@yahoo.comescribió en el mensaje
news:11**********************@d55g2000hsg.googlegr oups.com...
On Sep 26, 4:17 am, "MoRpHeOo" <morph...@gmail.comwrote:
Hi everybody,

¿can help me?,

I'm novice in C#,

can tell me what type of variable gives this operation.

Dim a As UInteger = 63689

Dim stringA As String = "w"

result = a + stringA

Thanks everybody
The variable type would probably be "InvalidCastException" as you are
performing an illegal call. It also seems that you have both Option
Explicit and Option Strict turned off. These should be turned on
almost 99.99% of the time.

Perhaps you are wanting to use the "+" operator for string
concatenation (which is the "&" operator in VB)? Then you could do
this:

Dim result As String = a.ToString() & stringA

If thats not what you were looking for, why not share what you are
trying to accomplish?

Thanks,

Seth Rowe
Sep 26 '07 #3

P: n/a
"MoRpHeOo" <mo******@gmail.comschrieb
Thanks Seth Rowe,

I don't wanna to concatenation the variable.

The entire function:

Dim a As UInteger = 63689
Dim b as UInteger = 568978
Dim result as UInteger = 0
Dim stringA As String = "WORK"

For i as Integer = 0 to 3
result = result * a + stringA(i)
a = a *b
Next

result = result and 2158975

Thanks, is so complex...
Which result do you expect? What do you 'result' expect to contain?

To get a single Char from the String:

stringA.Chars(i)

You can not calculate with chars. You can get the char's Unicode by using
System.Convert.ToUInt16:

dim c as char
dim code as ushort

c = stingsA.chars(i)
code = Convert.ToUInt16(c)

Armin

Sep 26 '07 #4

P: n/a
Again, why are you doing this? Your function makes absolutely no sense
to me, and is not even close to being valid code. If Armin's post
doesn't tell you what you needed, please tell us what you are trying
to accomplish and why. That way we might be able to help....

Thanks,

Seth Rowe

Sep 26 '07 #5

P: n/a
On Sep 26, 9:17 am, "MoRpHeOo" <morph...@gmail.comwrote:
Hi everybody,

¿can help me?,

I'm novice in C#,

can tell me what type of variable gives this operation.

Dim a As UInteger = 63689

Dim stringA As String = "w"

result = a + stringA

Thanks everybody
result is a type of string.

Sep 26 '07 #6

P: n/a

Thanks to all

The result is a integer of a + stringA in ascii.
"MoRpHeOo" <mo******@gmail.comescribió en el mensaje
news:e4**************@TK2MSFTNGP04.phx.gbl...
Hi everybody,

¿can help me?,

I'm novice in C#,

can tell me what type of variable gives this operation.

Dim a As UInteger = 63689

Dim stringA As String = "w"

result = a + stringA
Thanks everybody


Sep 26 '07 #7

P: n/a
MoRpHeOo wrote:
Thanks to all

The result is a integer of a + stringA in ascii.
Actually, it's not.

With Option Strict On, it causes a compiler error, as the conversion
from String to Double is disallowed.

With Option Strict Off, the result is a Double, but it causes a run time
error as the string can't be parsed into a Double. It's not getting the
character code from the first character, it's tryng to parse the entire
string.

In the other code that you posted, you are using a char instead of a
string. That causes a compiler error (even with Option Strict Off), as
the addition operator is not defined for an UInteger and a Char.

If you get the character code for the character, it's not an ASCII
character code, it's a Unicode character code.
"MoRpHeOo" <mo******@gmail.comescribió en el mensaje
news:e4**************@TK2MSFTNGP04.phx.gbl...
>Hi everybody,

¿can help me?,

I'm novice in C#,

can tell me what type of variable gives this operation.

Dim a As UInteger = 63689

Dim stringA As String = "w"

result = a + stringA
Thanks everybody

--
Göran Andersson
_____
http://www.guffa.com
Sep 26 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.