C# Error (Cannot Implicitly convert type ‘string’ to ‘int’)

The TxtAmountA.Text is a string. You are attempting to set the variable intAmountA which is an integer to a string value, thus the error. You need to parse the integer out of the string in the textbox. However, be aware that if what is in TxtAmountA.Text is not something that can be cast to an … Read more

Categories c# Tags

Carriage return and Line feed… Are both required in C#?

System.Environment.NewLine is the constant you are looking for – http://msdn.microsoft.com/en-us/library/system.environment.newline.aspx which will provide environment specific combination that most programs on given OS will consider “next line of text”. In practice most of the text tools treat all variations that include \n as “new line” and you can just use it in your text “foo\nbar”. Especially … Read more

How to delete object?

I need to create a method of class that delete the instance. I want to know if there is any possible solution (even if it is not recommended) how to do this. Instance of this class will be stored in hundreds of different class. I will try to describe this, for example there will be … Read more

regular expression “.*[^a-zA-Z0-9_].*”

.*[^a-zA-Z0-9_].* will match the entire input as long as there is a non-alphanumeric/underscore somewhere in the input. [^a-zA-Z0-9_] will match only a single non-alphanumeric/underscore character (most likely the last one, if you’re using the default greedy matching) if it is somewhere in the input. Which one you want depends on the input and what you want to do … Read more

num1 >= 0x80 – What is 0x80?

It is an integer literal – it’s the hex number 80, which is decimal 128. The “0x” prefix indicates it being in hex. For more details, look at the section 2.4.4.2 of the C# language specification: “Integer literals”.

Categories c# Tags