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

C#

 
AnswerRe: i need help............ Pin
OriginalGriff6-Mar-15 23:57
mveOriginalGriff6-Mar-15 23:57 
GeneralRe: i need help............ Pin
Richard MacCutchan7-Mar-15 3:03
mveRichard MacCutchan7-Mar-15 3:03 
GeneralRe: i need help............ Pin
OriginalGriff7-Mar-15 3:56
mveOriginalGriff7-Mar-15 3:56 
GeneralRe: i need help............ Pin
Richard MacCutchan7-Mar-15 4:15
mveRichard MacCutchan7-Mar-15 4:15 
GeneralRe: i need help............ Pin
OriginalGriff7-Mar-15 4:33
mveOriginalGriff7-Mar-15 4:33 
AnswerRe: i need help............ Pin
Afzaal Ahmad Zeeshan7-Mar-15 0:05
professionalAfzaal Ahmad Zeeshan7-Mar-15 0:05 
GeneralRe: i need help............ Pin
OriginalGriff7-Mar-15 2:21
mveOriginalGriff7-Mar-15 2:21 
AnswerRe: i need help............ Pin
Afzaal Ahmad Zeeshan7-Mar-15 3:09
professionalAfzaal Ahmad Zeeshan7-Mar-15 3:09 
Well, I do not have that much knowledge about compilers, how objects are created in low-level programming languages, in high-level programming languages, an object can be created as simple as,

C#
var name = "Hello world!";


And one doesn't even have to know what the object type is, where it is stored, how it is stored and so on. But, one thing that I do know is that a Warning shows bad code, not wrong code. There is a difference between them both, a bad code means that there is some sort of problem with the code which can be made better; e.g resources not called dispose or close function upon and so on.

Now coming to your claims, you said this code would throw warning,

C#
if (a == b);
   c();


But you didn't tell what type these objects hold. Are they strings, integers or a class object and so on. Also, there would again be a problem, the c, being static or not and so on. Now, let me talk about this scenario in a way, have a look at the following code,

C#
using System;
					
public class Program
{
	public static void Main()
	{
		string a = "", b = "";
		
		if(a == b) {
            new Program().c();
		}
	}
	
	void c() {
		Console.WriteLine("Hello world");
	}
}


The output of this code in the Console was, "Hello world". And the only warning that I got was on the line System.Collections.Generic, I didn't remove it because I was working on something in that fiddle[^].

What I believe is, that that would never throw an error, unless you, yourself compare objects of different type where a casting would give good results; good code.

I didn't bother trying to notice that semi-colon mistake of yours Griff, because I know you intended to write that, on purpose, to make sure I get a sense of wrong code, which I did! You succeeded. Smile | :)

The last thing there about the equality check or assignment operator, if someone has basic idea of these operators, he would never write equality check in a way someone would assign the value. If someone, by mistake does write the code in this way, I believe he doesn't even know the basics of operators in C# and he should learn them before doing anything at all.

Once again, I would say, a warning is compiler telling you that the source code would compile fine, would execute, but wait... you can write it this way to make it a better code. But I still want to know where I am wrong so that I can learn something. Smile | :)

Well, I hope that was not a lot for you to read. hehe Wink | ;)
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~

GeneralRe: i need help............ Pin
OriginalGriff7-Mar-15 3:55
mveOriginalGriff7-Mar-15 3:55 
GeneralRe: i need help............ Pin
Afzaal Ahmad Zeeshan7-Mar-15 3:59
professionalAfzaal Ahmad Zeeshan7-Mar-15 3:59 
GeneralRe: i need help............ Pin
manchanx7-Mar-15 4:30
professionalmanchanx7-Mar-15 4:30 
GeneralRe: i need help............ Pin
OriginalGriff7-Mar-15 4:35
mveOriginalGriff7-Mar-15 4:35 
GeneralRe: i need help............ Pin
Afzaal Ahmad Zeeshan7-Mar-15 4:41
professionalAfzaal Ahmad Zeeshan7-Mar-15 4:41 
GeneralRe: i need help............ Pin
BillWoodruff7-Mar-15 4:56
professionalBillWoodruff7-Mar-15 4:56 
GeneralRe: i need help............ Pin
OriginalGriff7-Mar-15 5:06
mveOriginalGriff7-Mar-15 5:06 
AnswerRe: i need help............ Pin
BillWoodruff7-Mar-15 5:05
professionalBillWoodruff7-Mar-15 5:05 
QuestionHelp me, very urgent problem, about after running the program design. Pin
Member 114460806-Mar-15 16:25
Member 114460806-Mar-15 16:25 
AnswerRe: Help me, very urgent problem, about after running the program design. Pin
Dave Kreskowiak6-Mar-15 17:58
mveDave Kreskowiak6-Mar-15 17:58 
GeneralRe: Help me, very urgent problem, about after running the program design. Pin
Member 114460807-Mar-15 16:51
Member 114460807-Mar-15 16:51 
AnswerRe: Help me, very urgent problem, about after running the program design. Pin
Richard MacCutchan6-Mar-15 21:40
mveRichard MacCutchan6-Mar-15 21:40 
AnswerRe: Help me, very urgent problem, about after running the program design. Pin
OriginalGriff6-Mar-15 21:47
mveOriginalGriff6-Mar-15 21:47 
GeneralRe: Help me, very urgent problem, about after running the program design. Pin
Member 114460807-Mar-15 16:50
Member 114460807-Mar-15 16:50 
GeneralRe: Help me, very urgent problem, about after running the program design. Pin
OriginalGriff7-Mar-15 21:03
mveOriginalGriff7-Mar-15 21:03 
GeneralRe: Help me, very urgent problem, about after running the program design. Pin
phil.o7-Mar-15 8:19
professionalphil.o7-Mar-15 8:19 
QuestionNeed help changing a value in an application Pin
hopper16-Mar-15 12:11
hopper16-Mar-15 12:11 

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.