|
hi take a look at my codes:
|
|
|
|
|
The client has to know where the server is. Period. There's no way that a server could notify the client of its address without the server being previously aware of the client - for the server to be previously aware of the client then the client would have had to have to connected to the server already!
In other words, what you have with localEndPoint2 is unnecessary. In order for the server to notify the client where it is they would already have to be connected and that would mean your problem is already solved.
Usually on the client side the server's IP Address and Port are stored in the application's configuration. Then the server starts up and starts listening on its port, and when the client starts up it reads its configuration and it knows where to connect to.
|
|
|
|
|
Hi,
I have Microsoft Access report in my .mdb file. In this database, i have one report which has attached to one table. From C#.net application,I want to open MsAccess database and get the reports per page and save as .DOC(as word document). Currently issue is that i connected to access database, opened report as well but when i am trying to save it,it's saving without any format like line or table (but on report i have layout like table/lines etc), NOT only that currently it's saving in only one .DOC file. I want to save per page from reports to my C:\test\ drive using C#.
Can someone help me pls.??
Thanks in advance.
|
|
|
|
|
Let me be the first to point out - using Access as a reporting tool is a REALLY bad idea.
Is there an export function in the Access report, I assume you are using a saveas function?
Can you export a report to word from withing Access?
If so create a macro and follow the steps, inspect the code created y the macro and then duplicate it in your app.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hi guyz...
-> i need some good articles or help regarding bluetooth programming in dotnet... i am also searching
the web but i am unable to find good one... plz help me out with this...
thanks...
take care...
J A Nasir K
|
|
|
|
|
Bluetooth is basically writing to COM ports so any COM port tutorial will suit your needs, or should.
|
|
|
|
|
|
So I have been reading through a lot of code lately. That is, code samples and articles and such on CodeProject and elsewhere. And at seemingly random times I notice a method or property is accessed with 'this.' before it. Is there really a rule to using it, or does it make for easy readability depending on the situation? I rarely ever use it and I would like to know if it's bad practice not to.
|
|
|
|
|
The this keyword provides access to the current instance of a class.
Information on this here[^].
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
You only need to use it to disambiguify tell which variable you actually mean. I.e.
private string parameter;
private void Method(string parameter)
{
this.parameter = "Class scope variable";
parameter = "Method scope variable";
} Or when you pass the current instance to a method:
private void Method(MyClass)
{
...
}
private void AnotherMethod()
{
Method(this);
} Using it unnecessarily just clutters the code and makes it harder to read IMO.
All those who believe in psycho kinesis, raise my hand.
My 's gonna unleash hell on your ass. tastic!
|
|
|
|
|
Okay, that makes plenty of sense. Thanks everyone for you input!
|
|
|
|
|
Unfortunately, this is a suggested requirement of FXCOP and it is a very poor programming practice. It is my opinion that the over-user of the this keyword came from ignorant programmers who did not know of the keyboard shortcut for intellisense (ctrl + space) these ignorant programmers then went on to define a standard because they wanted code to be "readable" thus it became a standard. It then made it into FXCOP which is a MS tool and then, because it is an MS tool other companies "architects" decided that if MS does it then it must be good. However, MS code rarely, if ever passed through the recommended FXCOP settings without warnings ... to make a long story short:
Don't use this unless you really need to. The only real good time to use the keyword is when calling a method from another object that required a reference to the calling object such as:
public class Foo{
public Foo(){
Bar bar = new Bar(this);
}
}
public class Bar{
public Bar(Foo foo){}
}
In all other cases where you would be tempted to use the keyword you have inappropriately named your local and member variables. Fix them.
|
|
|
|
|
A lot of MS's generated code uses this.xxx. I don't especially mind it but like you say it's not really necessary. It seems to be a hangover from Java where it appears to be the house style.
Kevin
|
|
|
|
|
Kevin McFarlane wrote: A lot of MS's generated code uses this.xxx
A FormX.Designer.cs is full of it. I guess the principles are:
1. In a container (such as a form) that holds many different objects, explicitly stating the object that you are using a method or property of is probably good practice and leaves no room for ambiguity.
2. It allows for parameters and fields to have the same name (much more likely to occur in auto generated code). If you always access the field with this then there will be no issues in this situation.
Personally, I only use it in my hand written code in case 2 and only where needed.
|
|
|
|
|
Those are good rules of thumb.
Kevin
|
|
|
|
|
I find I use this whenever I refer to a form object ie this.Close() but almost nowhere else, not even when referring to a control on the form, weird!
Still I hated using
Me in VB whereas this in c# doesn't offend me nearly as much!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: keyboard shortcut for intellisense (ctrl + space)
Thanks for the tip! How about this:
private SomeType i{get{return this;}}
public SomeMethod()
{
i.Close();
}
|
|
|
|
|
aspdotnetdev wrote: this (aka Me, aka i)
aka notThat
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
I use it to piss people off.
|
|
|
|
|
Hello once again. I just made a program to draw triangles in a way that makes a nice effect, here's a picture:
http://i276.photobucket.com/albums/kk2/Raztor0/Capture.jpg[^]
Now, the way I'm drawing this is I have an array of 80 points which I'm telling C# to draw with the DrawPolygon command. Can you see that line that goes through the middle of the triangles? That line is a line connecting the first and last point in the array, can I somehow prevent C# from connecting that last line? Is there a different command that lets me connect every point in sequence?
Thanks for your time
|
|
|
|
|
Hi,
a polygon[^] is a closed path by definition, and Graphics.DrawPolygon closes the path for you if you haven't done so yourself. That is all documented in MSDN. The class holds more drawing methods though.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Thank you for the info, but is there a way to connect each point without saying Graphics.DrawLine(pen, point, point)? I will do that if I have to but I really don't want to
|
|
|
|
|
Raztor0 wrote: is there a way to connect each point without ...
yes, and I already said that.
like always, it starts by reading the documentation.
I tend not to spoon feed lazy people.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Ah, alright. I didn't get that, I thought you were trying to say that DrawPolygon is explained there, which made me think that it's explaining what I already know. Thanks anyway, I'll go check it out.
|
|
|
|
|
Okay so I found DrawLines, this is exactly what I need :P Thank you for your help once again
|
|
|
|