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

C#

 
AnswerRe: import user32.dll in c# [modified] Pin
Lino Chacko12-Jul-09 6:12
Lino Chacko12-Jul-09 6:12 
GeneralRe: import user32.dll in c# Pin
dan!sh 12-Jul-09 7:13
professional dan!sh 12-Jul-09 7:13 
GeneralRe: import user32.dll in c# Pin
Mirko198013-Jul-09 0:20
Mirko198013-Jul-09 0:20 
GeneralRe: import user32.dll in c# Pin
Enver Maroshi13-Jul-09 1:30
Enver Maroshi13-Jul-09 1:30 
GeneralRe: import user32.dll in c# Pin
Mirko198013-Jul-09 2:48
Mirko198013-Jul-09 2:48 
QuestionHow to increase the scope in an if statement [modified] Pin
Nathan Revka11-Jul-09 12:50
Nathan Revka11-Jul-09 12:50 
AnswerRe: How to increase the scope in an if statement Pin
harold aptroot11-Jul-09 13:03
harold aptroot11-Jul-09 13:03 
AnswerRe: How to increase the scope in an if statement Pin
Luc Pattyn11-Jul-09 13:59
sitebuilderLuc Pattyn11-Jul-09 13:59 
Hi,

I'm not sure what you are doing, but it could be very wrong.

public void someMethod1() {
    if (time <= 3) {
        int fee = 2;
    }
    Console.WriteLine("Fee: {0:c}", fee);
}


does not compile since fee does not exist outside the if block.

public void someMethod1() {
    int fee = 0;
    if (time <= 3) {
        int fee = 2;
    }
    Console.WriteLine("Fee: {0:c}", fee);
}


does compile since fee exists outside the if block AND is guaranteed to hold a value.

int fee;  // or static int fee;
public void someMethod1() {
    fee=0;
    if (time <= 3) {
        fee = 2;
    }
    Console.WriteLine("Fee: {0:c}", fee);
}
public void someMethod2() {
    fee=0;
    if (time <= 2223) {
        fee = 2222;
    }
    Console.WriteLine("Fee: {0:c}", fee);
}


is probably not OK since both methods share a variable they did not intend to share. Both methods could run at the same time (using threads) and confusing each other.

If the data link between those methods is not intended, the methods really should use local variables.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.

AnswerRe: How to increase the scope in an if statement Pin
DaveyM6911-Jul-09 14:21
professionalDaveyM6911-Jul-09 14:21 
QuestionHelp me to convert this code in Java into a C# code Pin
Member 333548911-Jul-09 9:46
Member 333548911-Jul-09 9:46 
AnswerRe: Help me to convert this code in Java into a C# code Pin
OriginalGriff11-Jul-09 10:36
mveOriginalGriff11-Jul-09 10:36 
AnswerRe: Help me to convert this code in Java into a C# code Pin
Member 333548911-Jul-09 10:56
Member 333548911-Jul-09 10:56 
GeneralRe: Help me to convert this code in Java into a C# code Pin
DaveyM6911-Jul-09 11:35
professionalDaveyM6911-Jul-09 11:35 
GeneralRe: Help me to convert this code in Java into a C# code Pin
Member 333548911-Jul-09 16:14
Member 333548911-Jul-09 16:14 
GeneralRe: Help me to convert this code in Java into a C# code Pin
DaveyM6912-Jul-09 7:57
professionalDaveyM6912-Jul-09 7:57 
AnswerRe: Help me to convert this code in Java into a C# code Pin
Nathan Revka11-Jul-09 12:55
Nathan Revka11-Jul-09 12:55 
QuestionSearching a string in a binary file using BinaryReader Pin
SimpleData11-Jul-09 8:08
SimpleData11-Jul-09 8:08 
AnswerRe: Searching a string in a binary file using BinaryReader Pin
Eddy Vluggen11-Jul-09 8:28
professionalEddy Vluggen11-Jul-09 8:28 
GeneralRe: Searching a string in a binary file using BinaryReader [modified] Pin
SimpleData11-Jul-09 8:49
SimpleData11-Jul-09 8:49 
GeneralRe: Searching a string in a binary file using BinaryReader [modified] Pin
Eddy Vluggen11-Jul-09 10:32
professionalEddy Vluggen11-Jul-09 10:32 
GeneralRe: Searching a string in a binary file using BinaryReader Pin
Luc Pattyn11-Jul-09 14:08
sitebuilderLuc Pattyn11-Jul-09 14:08 
GeneralRe: Searching a string in a binary file using BinaryReader Pin
Eddy Vluggen12-Jul-09 0:54
professionalEddy Vluggen12-Jul-09 0:54 
GeneralRe: Searching a string in a binary file using BinaryReader Pin
Luc Pattyn12-Jul-09 5:20
sitebuilderLuc Pattyn12-Jul-09 5:20 
GeneralRe: Searching a string in a binary file using BinaryReader Pin
OriginalGriff11-Jul-09 10:48
mveOriginalGriff11-Jul-09 10:48 
GeneralRe: Searching a string in a binary file using BinaryReader Pin
harold aptroot11-Jul-09 13:19
harold aptroot11-Jul-09 13:19 

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.