Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I've encountered sometimes code like this and I am kind of new to programming. I want to find out what's the meaning behind those objects or data type enclosed in parenthesis.
(int)
(datagridview)
(form)
If you see something like this it's called a cast. It's used to explicitly convert a data type to another data type.
double pi = 3.14159;
int my_int = (int)pi;
See this description on casting for more details.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 days ago.
Improve this question
What is the use of another set of brackets in a multidimensional array? - such as
new Complex[2, 2][];
I get It's a 2 by 2 array. What is the use of the second []? Complex in this case is a Complex struct as defined by .net:
https://learn.microsoft.com/en-us/dotnet/api/system.numerics.complex?view=net-7.0
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Will the C# function Convert.ToInt32(text) convert different words to the same int? Any links or pushes in the right direction are appreciated!
P.S.
What about anagrams?
No, Convert.ToInt32(text) will just try to parse your text to an int, like:
Convert.ToInt32("032") will return 32 as int but
Convert.ToInt32("Brian") will throw an exception.
I assume that you want to have some kind of hashing, when you say "different words to the same int".
Try GetHashCode(). It will return the same value if you call it multiple times with the same value, for example:
"Brian".GetHashCode() will always return 1635321435
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How do I have it check my variable before allowing a click.
Example :
_StartControl.Click += new EventHandler(StartControl_Click);
I only want them to be able to do that if my variable "isValid" is equal to 1.
I'm not very good at forms.. Have always learned just console apps.
You can check the value of your isValid field inside StartControl_Click method. If the value is 1, you can allow the method to proceed, if it's not 1, you can simply return from the method before anything gets executed.
You can do it like this.
if(isValid==1)
_StartControl.Click += new EventHandler(StartControl_Click);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
In c# (or any language) accessing variable before it is being initialised,
what type of error is this?
A semantic error, syntactical or something else?
Example of the code that i had.
static string currencyConverterMenu =
"\n" +
"-Currency Converter-\n" +
currencyConverterList +
"0) Back to Main Menu\n";
static string currencyConverterList =
"1) Australian dollar\n" +
"2) United States dollar\n";
Console.WriteLine(currencyConverterMenu);
Syntax is about code rules like where to put semicolons, quotes of parenthesis.
Semantic is more about meaning and logic like what type of variable you must use or do you initialized it.
So it's semantic error.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Which method it is called on 3.ToString()?
System.Int16.ToString()
System.Int32.ToString()
System.Int64.ToString()
All integer literals in C# default to int (Int32) unless they are too big for int, in which case they become a larger data type that fits, like long(Int64).
So in this case, Int32.ToString() is called.
System.Int32.ToString() as literal integers are Int32 type