operation result int string

  • Thread starter Thread starter MoRpHeOo
  • Start date Start date
M

MoRpHeOo

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
 
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
 
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" <[email protected]> escribió en el mensaje
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
 
MoRpHeOo said:
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
 
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
 
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.
 
MoRpHeOo said:
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,

I'm sure even if you got an UInteger out of "W", you would overflow the
value of result by the end of the loop. If "W" gets a 1, then you are
looking at a number on the order of 568978 ^ 4 - 1, I think...
 
Back
Top