Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
To dolhaig:

I have been following your examples in the "system.net.NetworkInformation" within www.codeproject.com, and have put together a simple example on network detection. Here is my simple example in attempting to get my example working, but with no success. Could you get this simple example working for me? Thank you. It will tell me what I'm doing wrong. Samtoad, RSVP Please. Aug 3rd, 2019.

What I have tried:

            x  = 0;
/// my simple example. 
		using system;
		using system.net;
		namespace System.Net.NetworkInformation {
			if (NetworkInterface.GetIsNetworkAvailable()) {
		           xx = 1;
                 	}
			else {
			   xx = -1; 
			}
                        printf(" xx1 = %d\n", xx);
		}
Posted
Updated 4-Aug-19 19:29pm
Comments
Richard MacCutchan 4-Aug-19 6:03am    
That code is a strange mixture of C# and C++ (or is it C++/CLI?). I suggest you go back and take a closer look at the article.
samtoad 4-Aug-19 18:27pm    
Ok Richard M., 'OriginalGriff': Ok, a little clarification; This is not homework
and nor am I in any university programming class. I graduated from a State
university in the USA a long time ago; probably a long before you were even born.
Shortly after, I learned "C" out in
industry and have stayed with it. Through out my education and industry
experience, I've just picked up a style that I've stayed with and have never
been critized for, since I was doing the programming and it has done me well.
Just a thought: find out all the facts first before you jump down their
throats and start critizing their work. Hum...
Richard MacCutchan 5-Aug-19 3:30am    
Really, you graduated in the early 1940s? And quite frankly I have no idea what you are complaining about, you have got C# code (using statements, System.Net classes) and C/C++ (printf) mixed together. You declare a variable named x and then refer to it (I presume the same item) as xx. So my comment is not a criticism of your style but a statement of fact.
samtoad 5-Aug-19 23:11pm    
Ok richard, smart-alic! I graduated in 1984, from Utah State University, Logan, Utah.. NOT IN 1940. Each one of us has each his style.
Richard MacCutchan 6-Aug-19 4:22am    
Wow this is hard work. My comments have nothing to do with what you call your style (whatever that is supposed to mean). I am merely pointing out that you cannot use C# code and C/C++ code in the same source. Neither compiler will be able to understand it.

You have used two different names for your check variable. Use proper names and such errors become much easier to see. Also, why are you using the variable in the first place? Just print a comment for both cases from the if statement.
C++
if (NetworkInterface.GetIsNetworkAvailable()) {
    printf("Interface available\n");
}
else {
    printf("No interfaces found\n");
}
 
Share this answer
 
If you got the code from an article, then there is a "Add a Comment or Question" button at the bottom of that article, which causes an email to be sent to the author. They are then alerted that you wish to speak to them.
Posting this here relies on them "dropping by" and realising it is for them.

But ... code that won't even compile, and adding a deadline? Hmmm ... we are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
 
Share this answer
 
v2
Thanks Richard M.(Richard MacCutchan), I hope 'originalgriff' is listening in...

Ok, the title of the question was in poor taste, I was not implying anything demanding or in bad taste. I had been banging on it for a long time, trying to get it to go, but no avail. I was frustrated. Not knowing that C++ and C# code can not be mixed directly - it's kinda like you have to do a go around with it. No, I did not know that you could send a msg to the author as 'originalgriff' so stated on the bottom of the page. After doing a little snooping and paying for it, I was led to an area where I was shown how to make a C#(I hope) DLL file and what are the C# dll schematics/templates on how I could make one. Your solution, as I've seen many times before, is in the very heart of the C# DLL template - which are new things that I'm learning how to do. Thanks, Samtoad.
Remember, each programmer/developer has their own style, and I should have documented mine. Thx.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900