|
Thank you so much for this information!
I actually was not sad with you, you're right, I should gougle it first, but yesterday I posted a few questions after googling with no success and since I was here I just asked - my mistake and I'm sorry.
Thanks again for your help,
Dirso
|
|
|
|
|
If you want to be able to change the values X, Y or Z after the instance has been created, you should make it a class. A struct should be immutable, to avoid situations where you would modify a copy of the data that you actually wanted to modify.
A struct is a bit tricker to implement correctly, so until you have read up a bit on the subject you should just stick to classes.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks! Performance could be an issue here, so if struct is faster I'll go for it. about change values I'll try to use "out"/"ref" parameters everytime, right?
Thanks,
Dirso
|
|
|
|
|
Dirso wrote: Performance could be an issue here, so if struct is faster I'll go for it.
If you have an array of the type, a structure uses less memory, which can improve performance a bit. A struct is faster for some operations, but you have to keep it smaller than 16 bytes to be efficient.
Dirso wrote: about change values I'll try to use "out"/"ref" parameters everytime, right?
That doesn't help, as you would still change the vales of a copy, which doesn't affect the original.
A structure should be immutable, i.e. you assign the values when you create the instance, and if you want to change a value you create a new instance. That way the structure instance works as a single value, which is the intention of the structure concept.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hello everyone,
I've got a little problem.
I made a project and it runs well. In the project I access a database, I create table and access them. The database I use is Microsoft SQL Server 2005, the free database from Microsoft. After I installed it, I enter a connectionstring like this: DERESEN\SQLEXPRESS and it will work fine. So I tried it with my friends computer and it didn't work, I had to change the name (DERESEN) in the computer's name, so I did it like this: Environment.MachineName + "\SQLEXPRESS". And it did work.
Now the problem: I need to get it work on every (Windows-based) computer, so I let my girlfriend instal it at her computer (a computer no-no should be able to do it), but it didn't work. I let her instal SQL Server 2005 and it didn't work.
So now my question:
Is there any database which is ALWAYS installed on a windows computer which I can access. Or is there another way (which I didn't see) to get a database running?
I hope you can help me, because I've been searching for days for an answer to this problem.
|
|
|
|
|
Deresen wrote: Is there any database which is ALWAYS installed on a windows computer which I can access.
No.
Deresen wrote: Or is there another way (which I didn't see) to get a database running?
You could always use SQL Server Compact Edition[^]. This runs inside the process space of the application (it runs as a DLL) and it's free.
|
|
|
|
|
Use .\SQLEXPRESS or (local)\SQLEXPRESS
More about connection strings[^]
And make sure that the database is attached to the server.
Sql server (not windows) has its system databases that you should not manipulate.
Eslam Afifi
modified on Thursday, September 11, 2008 8:17 PM
|
|
|
|
|
Eslam is correct, but SQL Server has to be installed with the "default instance" to be able to do that. If someone installs it using a "named instance" and calls it something else, it won't work.
|
|
|
|
|
Deresen wrote: Is there any database which is ALWAYS installed on a windows computer which I can access
No.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
You can use SQLite[^] for your purposes. It's just a single file database. There is also ado.net managed provider for it: System.Data.SQLite[^]
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
This is probably a simple question, but how do I open another application from a Windows form?
What I basically want to do is execute a search for a file or files, have those files appear in a listbox, then have the application open the selected file using a specific application installed on the user's desktop. It's basically a simplified Windows search application designed for a very specific purpose.
Thanks.
|
|
|
|
|
Use System.Diagnostics.Process.Start to start the application. If the file is associated with a default application, that application will be started up - so, for instance, executing Process.Start(@"c:\MyFile.doc"); would start Word and load that document.
|
|
|
|
|
System.Diagnostics.Process.Start
Eslam Afifi
|
|
|
|
|
I have 6 tabs on my windows forms. I want it to change tabs with I click the next button can you any help.
Shelby Learning the Code!
|
|
|
|
|
Call SelectedTab and select the tab you want.
|
|
|
|
|
private void Navigate()
{
//this.tabControl1.SelectedTab = this.tabPage1;
//this.tabControl1.SelectedTab = this.tabPage2;
//this.tabControl1.SelectedTab = this.tabPage3;
//this.tabControl1.SelectedTab = this.tabPage4;
//this.tabControl1.SelectedTab = this.tabPage5;
}
This is what I have. I need with I click the Next button it on to tab 2 if I press again tab 3 and so on. I click the previous button it goes backward.
Shelby Learning the Code!
|
|
|
|
|
So keep track of which tab you're on and use that as the basis for navigation.
|
|
|
|
|
Need help in writing this.
Shelby Learning the Code!
|
|
|
|
|
Name 2 buttons "btnPrev" and "btnNext". Name a tab control "tabControl1". Create "Click" event handlers for the two buttons and put the code in them like this:
private void btnPrev_Click(object sender, EventArgs e)
{
if (tabControl1.SelectedIndex > 0)
tabControl1.SelectedIndex--;
}
private void btnNext_Click(object sender, EventArgs e)
{
if (tabControl1.SelectedIndex < (tabControl1.TabCount - 1))
tabControl1.SelectedIndex++;
}
|
|
|
|
|
Hi,
I found several answer about typedef with "using" but it doensn't fit to my problem...
I'd like to do something like this in C#
typedef float Real;
because, someday I may need to create my own class Real and then I wouldn't need to replace every word (I know I could use the visual studio editor "Replace All" option, but I think it's too dangerous if I'm in the middle of a project that could have up to 1000s of files.
Thanks,
Dirso
|
|
|
|
|
However, you could create a wrapper class at the expense of speed. It really is unfortunate that you cannot inherit base types in .NET.
Another option which is more sloppily elegant ... Create a new class whose only method is a static, implicit operator that converts between itself and the type you want.
Then declare your code using floats in the following manner:
float myFloat = ((MyClass)5f);
When it comes time to change the value of the float change the implicit operator's type and you will get compile time errors showing you every location that needs to be changed.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
What have you tried so far? In what way does it not fit?
|
|
|
|
|
C# has a very natural equivalent for this:
The C# equivalent of:
typedef float Real;
is simply:
using Real = System.Single;
Note that you can't use the C# aliased name on the right side, it must be the 'proper' type name.
David Anton
http://www.tangiblesoftwaresolutions.com
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
VB & C# to Java Converter
Java to VB & C# Converter
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: convert VB, C#, or Java to C++/CLI
|
|
|
|
|
My problem about that is that I'd like to define it once, not in every single file.
Thanks anyway for trying,
Dirso
|
|
|
|
|
Oh, then pass your code through the C-preprocessor, it's good at hiding details like that.
|
|
|
|