|
Drag and drop it on the recycle bin.
|
|
|
|
|
What's with all the smilies. Are you joking or asking a serious question?
If you are trying web deployement, you can read this [^] good blog post.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
In my projects I always have 4 libraries:
- Gui
- Logic
- Database
- Data structs
Usually, there are some additional libraries, but it doesn't matter.
In "Data structs" (as the name suggests) I hold all the data structures. And I always hold them in classes. And never thought they should be structs. How are you holding data structs? What advantages and disadvantages you see?
Don't forget to rate answer, that helped you. It will allow other people find their answers faster.
|
|
|
|
|
From the dictionary, a structure is:
1. a complex construction or entity
2. the arrangement and interrelationship of parts in a construction, such as a building
3. the manner of construction or organization the structure of society
4. (Life Sciences & Allied Applications / Biology) Biology morphology; form
5. (Chemistry) Chem the arrangement of atoms in a molecule of a chemical compound the structure of benzene
6. (Earth Sciences / Geological Science) Geology the way in which a mineral, rock, rock mass or stratum, etc., is made up of its component parts
7. Now rare the act of constructing
This means that you are semantically OK using a class as a structure, because you aren't referring to the struct keyword. I hope that makes sense.
|
|
|
|
|
Pete O'Hanlon wrote: I hope that makes sense
Don't know about that, but it looks classy and well structured.
|
|
|
|
|
Luc Pattyn wrote: it looks classy and well structured
But the list doesn't even start at 0.
|
|
|
|
|
Maybe zero hadn't been invented yet when Pete bought his dictionary? Anyway, it doesn't degrade the quality of the definition.
|
|
|
|
|
In most projects I quite often have occasion to think I should use a struct. But I almost always end up transforming it into a class for some reason!
Kevin
|
|
|
|
|
What is the logic as in ASP.NET application the page will not be sent if any control is not validated?
I've got dialog box with Ok and Cancel button. If any validated item (edit box) is not valid, then Ok button click should not close dialog box but only Cancel can do that?
Чесноков
|
|
|
|
|
Your question is a little confusing but I'll take a stab at your question.
You cannot use the basic MessageBox for what you want to do. You creat a form, design it as a dialog, and put your own code in the form to accomplish that.
Now if you are really sharp then you can do something like this:
Create the form and make the constructor require an IValidator class passed in the constructor. Add an OkayButton CancelButton and make the OkayButton disabled.
Define your interface for IValidator.
The Validator will implement it's own rules for what is valid and what is invalid.
As the data is entered into the form, the data is passed into the validator such that OkayButton.Enabled = Validator.IsValid( entryBox.Text );
As long as the data is valid (or once it is valid) the button will light up. As long as it is invalid it remains disabled.
By doing this, you have an extensible dialog box that can have an infinite number of validation rules without ever having to change a line of code in the control.
|
|
|
|
|
Dear Coders,
It seems that this topic is somewhat controversial.
Should we use structs in c# or not.
My projects requires a collection of data that does not fall into any specific catagory for any of my classes, but will be required for use by more than one of them.
It is a bunch of different data types where enum does not fit my needs.
I have seen structs used in c#, but have also read that whereever possible to stick with objects.
I am confused, as surely they would have been totaly replaced by objects if they should not be used?
If it is better to use objects, is it valid to create such an object that has no public or private methods other than its constructor, and instead has a bunch of public variable declerations?
Thank you
Steve
|
|
|
|
|
When in doubt, use a class instead of a struct.
Good structs are small and often short-lived (such as Point and Size).
Avoid big structs; my rule of thumb: any struct larger than 16 bytes is suspicious.
structs can do a few things classes can't; e.g. they are fine when representing value types with overloaded operators (e.g. a struct representing a complex number).
|
|
|
|
|
The difference between structs and classes is fairly simple (Doesn't make sense to differentiate between structs and "objects," since EVERYTHING is an object, including a struct).
Structure-type variables contain the actual structure. Class-type variables contain a POINTER to the actual class. That means multiple variables can point to the same class, but only one variable can point to a given structure. If you type a = b where 'b' is a structure, 'a' will gain a COPY of that structure. If 'b' is a class, 'a' will just point to the same class, so if you make changes to 'a', you'll see the same result in 'b'.
Structures are more efficient for small, immutable objects (Objects that cannot be changed once created). Classes are good for everything else. Of course there are exceptions to this, but that's a good starting point.
stephen.darling wrote: If it is better to use objects, is it valid to create such an object that has no public or private methods other than its constructor, and instead has a bunch of public variable declerations?
That's bad practice... In most cases, you don't want to expose variable declarations. Make properties or methods to return them, so you can control the flow of data.
|
|
|
|
|
Thanks for the responce everone!
Steve
|
|
|
|
|
Hello,
I have a simple multi-tier winform application (c# and SQL database) where I want to add some reporting functions. Business Logic, DataAcces layer and UI are the most important Layers in my project.
I am searching for a flexible way to add the reporting so I thought to do it by adding an extra class libary project to my sollution where i handle the reporting. I hope this makes it possible to deploy the dll to my clients when a report changement take place.
Is there someone who:
- have a sample solution
- show me how to access reports form the libary class
- know a better/easyer way to add a flexible reporting function to a winform application.
Thanks for advise.
|
|
|
|
|
The Best way is to Create a Webservice that you win app can consume and when you change the web service in one place you dont need to change it in other apps.
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
With List those lines are valid:
List<string> strs = new List<string>()
{
"helo",
"yes"
};
How to perform the same with Dictionary ?
Dictionary<MyType, string> dict = new Dictionary<MyType, string>()
{
Yes, "yes",
No, "no"
};
Чесноков
|
|
|
|
|
|
that is great thanks
Чесноков
|
|
|
|
|
hey guys..i need some help...i want to connect a MySql database in the other pc...i will develop a program which will be used over the network in the office..i searched something over web and i wrote my codes as i sunderstand from the sites that i searched...but i have such problem when i run the program it gives error like "Unable to connect any of the specified MySql hosts"...i opened 3306 port from the modem..but still i have that problem..here is my codes
try
{
MySqlConnection connect = new MySqlConnection("Data Source=SErver_ip;database=dbname;user id=xxx;password=1");
connect.Open();
Console.WriteLine("Bağlantı Durumu : {0}", connect.State);
connect.Close();
}
catch(exception ex)
{
Console.WriteLine(ex.Message);
}
Where is my mistake??
or any other suggesstion ?
|
|
|
|
|
Too me your connection string doesn't look right compare it too this site and let us know if it works
Connection Strings[^]
As barmey as a sack of badgers
Dude, if I knew what I was doing in life, I'd be rich, retired, dating a supermodel and laughing at the rest of you from the sidelines.
|
|
|
|
|
yeah i compared my connection string with the site one and then i used the same string the one which was suggested by site but still same error...should i make any settings in the server machine?
or do i need mysql in my pc also or just connector is enough ?
|
|
|
|
|
if your using the database name etc as variables then make sure you have concatinated them properly into the string
i.e. "Server=" + ServerName + ";Database="
As barmey as a sack of badgers
Dude, if I knew what I was doing in life, I'd be rich, retired, dating a supermodel and laughing at the rest of you from the sidelines.
|
|
|
|
|
no man..i am not using them as variables...so do u have any other suggestion ?
|
|
|
|
|
erdinc27 wrote: MySqlConnection connect = new MySqlConnection("Data Source=SErver_ip;database=dbname;user id=xxx;password=1");
shoudn't be:
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
beside what qwertz321 told you, you need to check the firewall on a computer that has MySQL installed. For testing purposes you can disable firewall and you will know if firewall is the culprit.
|
|
|
|