Click here to Skip to main content
15,885,546 members
Home / Discussions / C#
   

C#

 
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 
It is because TXTC and TXTF are both local to the methods that they are created in. You need to create them at the class level so they are visible to both methods, thus:
C#
public partial class Weather : System.Web.UI.Page
{
    int TXTC; // will be visible to both event handlers
    int TXTF;

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {
        String C = TextBox1.Text;
        TXTC = Int32.Parse(C); // already defined at class level
        string TXTC1 = TXTC.ToString();
        TXTC = (TXTF - 32) * (5 / 9);
    }

    protected void TextBox2_TextChanged(object sender, EventArgs e)
    {
        String F = TextBox2.Text;
        TXTF = Int32.Parse(F);
        string TXTF1 = TXTF.ToString();
        TXTF = (TXTC) * (9 / 5) + 32;
    }
}


You should read up on the concept of "scope" in C# (and other languages) for a fuller explanation.
AnswerRe: The name does not exist in the current context Pin
OriginalGriff11-Nov-20 23:06
mveOriginalGriff11-Nov-20 23:06 
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 
GeneralRe: How to find days between a defined date and now? Pin
Alex Dunlop10-Nov-20 16:57
Alex Dunlop10-Nov-20 16:57 
GeneralRe: How to find days between a defined date and now? Pin
Gerry Schmitz10-Nov-20 18:11
mveGerry Schmitz10-Nov-20 18:11 
AnswerRe: How to find days between a defined date and now? Pin
Mycroft Holmes11-Nov-20 11:12
professionalMycroft Holmes11-Nov-20 11:12 
QuestionJSON "classes" repetitive Pin
Member 56973910-Nov-20 6:25
Member 56973910-Nov-20 6:25 
AnswerRe: JSON "classes" repetitive Pin
Gerry Schmitz10-Nov-20 7:24
mveGerry Schmitz10-Nov-20 7:24 
GeneralRe: JSON "classes" repetitive Pin
Member 56973910-Nov-20 8:06
Member 56973910-Nov-20 8:06 
GeneralRe: JSON "classes" repetitive Pin
Gerry Schmitz10-Nov-20 14:33
mveGerry Schmitz10-Nov-20 14:33 
QuestionColor the intersected rectangles in c# windows applicaion Pin
Member 147377589-Nov-20 19:47
Member 147377589-Nov-20 19:47 
AnswerRe: Color the intersected rectangles in c# windows applicaion Pin
OriginalGriff9-Nov-20 20:12
mveOriginalGriff9-Nov-20 20:12 
QuestionLINQ results getting modified? Pin
Stellar Developer9-Nov-20 13:52
Stellar Developer9-Nov-20 13:52 
AnswerRe: LINQ results getting modified? Pin
Gerry Schmitz9-Nov-20 14:49
mveGerry Schmitz9-Nov-20 14:49 

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.