Click here to Skip to main content
15,887,596 members
Home / Discussions / C#
   

C#

 
GeneralRe: Multiple clicks on one button scrolls through selection choices Pin
Luc Pattyn10-May-18 6:24
sitebuilderLuc Pattyn10-May-18 6:24 
GeneralRe: Multiple clicks on one button scrolls through selection choices Pin
OriginalGriff10-May-18 6:44
mveOriginalGriff10-May-18 6:44 
GeneralRe: Multiple clicks on one button scrolls through selection choices Pin
Luc Pattyn10-May-18 6:55
sitebuilderLuc Pattyn10-May-18 6:55 
GeneralRe: Multiple clicks on one button scrolls through selection choices Pin
OriginalGriff10-May-18 7:59
mveOriginalGriff10-May-18 7:59 
AnswerRe: Multiple clicks on one button scrolls through selection choices Pin
BillWoodruff10-May-18 10:56
professionalBillWoodruff10-May-18 10:56 
AnswerRe: Multiple clicks on one button scrolls through selection choices Pin
Pete O'Hanlon10-May-18 21:45
mvePete O'Hanlon10-May-18 21:45 
Questionc# while loop Pin
swathiii8-May-18 23:04
swathiii8-May-18 23:04 
AnswerRe: c# while loop Pin
OriginalGriff8-May-18 23:37
mveOriginalGriff8-May-18 23:37 
That won't compile. Why not? You don't declare tem2, and if you do, you need to give it a default value or you can't return it.
In addition there is no good reason for a local function here: it just makes the code harder to read.

If it doesn't compile, it doesn;t generate an executable file, so the version you run is the last "compile error free" version of your source code.
Fix the compilation errors, and it may work better:
public static void Main(string[] args)
    {

    int ip1, ip2, ip3, ip4, res, tem2 = 0;
    ip1 = Int32.Parse(Console.ReadLine());
    ip2 = Int32.Parse(Console.ReadLine());
    ip3 = Int32.Parse(Console.ReadLine());
    ip4 = Int32.Parse(Console.ReadLine());
    res = summeet(ip1, ip2, ip3, ip4);
    Console.WriteLine(res);
    }
private static int summeet(int p1, int p2, int p3, int p4)
    {
    int a, b, c, n, tem1, tem2 = 0, i = 0, d1, d2;
    a = p1;
    b = p2;
    c = p3;
    n = p4;
    while (i > n - 3)
        {
        d1 = b - a;
        tem1 = d1 + c;
        d2 = c - b;
        tem2 = tem1 + d2;
        i++;
        tem1 = tem2;
        }
    return tem2;
    }
But do yourself a favour: stop using as-short-as-possible names for things: it may seem like a waste of time and more work, but using descriptive names makes your code document itself, and that means it's more readable. It also means it's a lot easier to tell when you used the wrong variable, and that makes your code more reliable and easier to debug. the variables a, b, c, and n are unnecessary, you can use the parameters directly instead; and give them sensible names instead of "p1", "p2" and so on. That way, when you want to use the method later, Visual Studio will even prompt you as to what value belongs in what parameter!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!

AnswerRe: c# while loop Pin
Pete O'Hanlon9-May-18 1:32
mvePete O'Hanlon9-May-18 1:32 
AnswerRe: c# while loop Pin
Luc Pattyn9-May-18 22:53
sitebuilderLuc Pattyn9-May-18 22:53 
Questionhow can i get the splitted values in a textbox from seperate line in c# using text file Pin
Mohamed Fahad M8-May-18 3:28
Mohamed Fahad M8-May-18 3:28 
AnswerRe: how can i get the splitted values in a textbox from seperate line in c# using text file Pin
OriginalGriff8-May-18 4:14
mveOriginalGriff8-May-18 4:14 
AnswerRe: how can i get the splitted values in a textbox from seperate line in c# using text file Pin
Eddy Vluggen8-May-18 5:51
professionalEddy Vluggen8-May-18 5:51 
GeneralRe: how can I ... Pin
Luc Pattyn8-May-18 7:16
sitebuilderLuc Pattyn8-May-18 7:16 
GeneralRe: how can I ... Pin
Eddy Vluggen8-May-18 7:43
professionalEddy Vluggen8-May-18 7:43 
AnswerRe: how can i get the splitted values in a textbox from seperate line in c# using text file Pin
BillWoodruff12-May-18 10:45
professionalBillWoodruff12-May-18 10:45 
Questionconversion from Uint32 to float Pin
sp love8-May-18 2:16
sp love8-May-18 2:16 
AnswerRe: conversion from Uint32 to float Pin
Luc Pattyn8-May-18 2:56
sitebuilderLuc Pattyn8-May-18 2:56 
QuestionWebServices Pin
Member 22364197-May-18 23:17
Member 22364197-May-18 23:17 
AnswerRe: WebServices Pin
Eddy Vluggen7-May-18 23:38
professionalEddy Vluggen7-May-18 23:38 
AnswerRe: WebServices Pin
OriginalGriff7-May-18 23:43
mveOriginalGriff7-May-18 23:43 
GeneralRe: WebServices Pin
Member 22364198-May-18 19:35
Member 22364198-May-18 19:35 
GeneralRe: WebServices Pin
Mycroft Holmes8-May-18 20:31
professionalMycroft Holmes8-May-18 20:31 
Questionc# Why can I not get this to work? Pin
tomas0007-May-18 1:21
tomas0007-May-18 1:21 
AnswerRe: c# Why can I not get this to work? Pin
Luc Pattyn7-May-18 2:42
sitebuilderLuc Pattyn7-May-18 2:42 

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.