Click here to Skip to main content
15,890,845 members
Home / Discussions / C#
   

C#

 
SuggestionRe: A proper way to return a list (Xamarin, CollectionView, Realm) Pin
Richard MacCutchan14-Nov-20 6:07
mveRichard MacCutchan14-Nov-20 6:07 
GeneralRe: A proper way to return a list (Xamarin, CollectionView, Realm) Pin
Member 1499286214-Nov-20 9:10
Member 1499286214-Nov-20 9:10 
GeneralRe: A proper way to return a list (Xamarin, CollectionView, Realm) Pin
OriginalGriff14-Nov-20 9:16
mveOriginalGriff14-Nov-20 9:16 
AnswerRe: A proper way to return a list (Xamarin, CollectionView, Realm) Pin
Mycroft Holmes14-Nov-20 12:18
professionalMycroft Holmes14-Nov-20 12:18 
GeneralRe: A proper way to return a list (Xamarin, CollectionView, Realm) Pin
Member 1499286216-Nov-20 8:17
Member 1499286216-Nov-20 8:17 
QuestionHow to selected value of a dropbox column of a DataGridView programmatically? Pin
Alex Dunlop13-Nov-20 0:41
Alex Dunlop13-Nov-20 0:41 
AnswerRe: How to selected value of a dropbox column of a DataGridView programmatically? Pin
Richard MacCutchan13-Nov-20 1:55
mveRichard MacCutchan13-Nov-20 1:55 
GeneralRe: How to selected value of a dropbox column of a DataGridView programmatically? Pin
Richard Deeming13-Nov-20 2:06
mveRichard Deeming13-Nov-20 2:06 
GeneralRe: How to selected value of a dropbox column of a DataGridView programmatically? Pin
Richard MacCutchan13-Nov-20 2:16
mveRichard MacCutchan13-Nov-20 2:16 
GeneralRe: How to selected value of a dropbox column of a DataGridView programmatically? Pin
Alex Dunlop13-Nov-20 3:09
Alex Dunlop13-Nov-20 3:09 
AnswerRe: How to selected value of a dropbox column of a DataGridView programmatically? Pin
Gerry Schmitz13-Nov-20 4:10
mveGerry Schmitz13-Nov-20 4:10 
QuestionCommented code in c# forms does it affect the performance Pin
Sachin Kulkarni B12-Nov-20 4:50
Sachin Kulkarni B12-Nov-20 4:50 
AnswerRe: Commented code in c# forms does it affect the performance Pin
OriginalGriff12-Nov-20 5:08
mveOriginalGriff12-Nov-20 5:08 
GeneralRe: Commented code in c# forms does it affect the performance Pin
trønderen12-Nov-20 7:22
trønderen12-Nov-20 7:22 
AnswerRe: Commented code in c# forms does it affect the performance Pin
Gerry Schmitz13-Nov-20 3:58
mveGerry Schmitz13-Nov-20 3:58 
QuestionThe name does not exist in the current context Pin
darkdxd11-Nov-20 22:04
darkdxd11-Nov-20 22:04 
AnswerRe: The name does not exist in the current context Pin
Richard Deeming11-Nov-20 23:01
mveRichard Deeming11-Nov-20 23:01 
AnswerRe: The name does not exist in the current context Pin
trønderen11-Nov-20 23:01
trønderen11-Nov-20 23:01 
AnswerRe: The name does not exist in the current context Pin
Richard MacCutchan11-Nov-20 23:03
mveRichard MacCutchan11-Nov-20 23:03 
AnswerRe: The name does not exist in the current context Pin
OriginalGriff11-Nov-20 23:06
mveOriginalGriff11-Nov-20 23:06 
all objects in C# have what is called scope - they only exist within the area of code delimited by curly brackets - in this case the function.
So if I write this:
C#
private int aClassVariable = 666;
private void foo(int aParameter)
   {
   int aVaraiable = 999;
   if (aParameter > 0)
      {
      int anotherVariable = aParameter / 2;
      }
   }
Then the scope of the variables is as follows:
aClassVariable  is available to all code in the class.
aParameter      is available to all code in the method foo, but not outside it.
aVaraiable      is available to all code in the method foo, but not outside it.
anotherVariable is available to code only within the if block

Since TXTC is is declared within the TextBox1_TextChanged method of your code, it is only available within that method, and does not exist for any other code.

What can you do about it? Move TXTC to class level: declare it outside any method, and mark it as private.
But ... you will have to give it a default value or your code will probably not compile, and you probably need to check in TextBox2_TextChanged to see if it's got a "real value" before you use it in case the user types in the boxes the wrong way round!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!

QuestionHow to find days between a defined date and now? Pin
Alex Dunlop10-Nov-20 7:51
Alex Dunlop10-Nov-20 7:51 
AnswerRe: How to find days between a defined date and now? Pin
Richard MacCutchan10-Nov-20 8:56
mveRichard MacCutchan10-Nov-20 8:56 
GeneralRe: How to find days between a defined date and now? Pin
Alex Dunlop10-Nov-20 16:48
Alex Dunlop10-Nov-20 16:48 
GeneralRe: How to find days between a defined date and now? Pin
Richard MacCutchan10-Nov-20 21:57
mveRichard MacCutchan10-Nov-20 21:57 
AnswerRe: How to find days between a defined date and now? Pin
Gerry Schmitz10-Nov-20 14:51
mveGerry Schmitz10-Nov-20 14:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.