|
VBA.Collection p = new VBA.Collection()
.. or use a more specified type of collection, like ArrayList
|
|
|
|
|
I have created a window project with the name winProject and it's database is in sql server 2005 the name is winDatabase
Now i want to create a setup that installs the project(winProject)
and it's database(winDatabase)
Please reply me
|
|
|
|
|
Take a look at WiX[^] that has the ability to install SQL databases.
I doubt it. If it isn't intuitive then we need to fix it. - Chris Maunder
|
|
|
|
|
Is there a way to test if the cast will work before actually doing the cast? My app will spend a lot of time testing for valid casts and many times the cast won't be valid so I want to avoid the overhead of catching the InvalidCastException.
TIA
|
|
|
|
|
Use is keyword.
if(yourObject is SomeType)
. Or use as keyword
obj = yourObject as SomeType;
if(obj != null)
|
|
|
|
|
Single and Int32 are non nullable value types so can't be used with 'is' and 'as'
|
|
|
|
|
Ohh I haven't noticed the single and int32 in the title. I am sorry.
|
|
|
|
|
Why would casting from a single to an int not be valid, is there something you're not telling us?
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Errr, yes, I am telling you my example was stupid
Basically is there a way when casting between value types to work out if a cast will work without testing it and catching Invalidcast or Overflow?
|
|
|
|
|
I don't think there is...
I reckon the best you can do is check the float isn't too big, too small, ot is NaN. You could write up a little method:
public bool ConvertSingleToInt(float Single, out int Integer)
{
Integer = 0;
if(Single > int.MaxValue || Single < int.MinValue || float.IsNaN(Single) ) )
return false;
Integer = (int)Single;
return true;
}
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
I am coming to the same conclusion, thanks for your help. I am actually considering just going down the exception catching route - if its slow when a cast is invalid or overflows then it's a great indicator that those casts shouldn't be attempted in the first place.
|
|
|
|
|
Have you looked at the Int32Converter class and its CanConvertFrom method? There are xxxConverter classes for all the integral data types I believe.
Dave
|
|
|
|
|
I have looked at those but they don't seem to take into account the data in the variable being cast, just if a converter exists or not.
|
|
|
|
|
Int32.TryParse would be the way to go I think.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
That only accepts a string
|
|
|
|
|
Int32 intval;
Single s = 88;
Int32.TryParse(s.ToString(), out intval);
Job Done.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
I know but these casts could be executed 100s of millions of times - I don't want to take the hit of converting everything to a string first.
|
|
|
|
|
Fair enough, but I bet its quicker perfoming than writing a function to see if it can be done. I would probably go with one of the earlier suggestions, put it in a try catch - unless you are expecting millions to fail?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
That's what I have decided to do - just use exceptions. I don't expect many of them to fail but the casting forms part of a simple domain specific language so some users could try to do lots of ridiculous casts. Still... sod 'em - ridiculous things will run ridiculously slowly
|
|
|
|
|
Hello everyone,
Suppose my C# application is pure managed code (C#), for such types of application, CLSCompliantAttribute should be always true?
Are there any other points to be considered to consider whether or not it is complaint?
http://msdn.microsoft.com/en-us/ms182156.aspx
thanks in advance,
George
|
|
|
|
|
Hi, I am getting the compile error and cannot see why it is wrong. I am learning C# so I am pretty new to this. Here is the code I am trying to compile
using System;
using System.Windows.Forms;
namespace MyForm
{
public class MyForm : Form
{
private TextBox txtEnter;
private Label lblDisplay;
private Button btnOk;
public MyForm ()
{
this.txtEnter = new TextBox();
this.lblDisplay = new Label();
this.btnOk = new Button();
this.Text = "My HelloWin App!";
// txtEnter
this.txtEnter.Location = new System.Drawing.Point(16, 32);
this.txtEnter.Size = new System.Drawing.Size(264, 20);
//lblDisplay
this.lblDisplay.Location = new System.Drawing.Point(16, 72);
this.lblDisplay.Size = new System.Drawing.Size(264, 20);
//btnOk
this.btnOk.Location = new System.Drawing.Point(88, 224);
this.btnOk.Text = "OK";
this.btnOk.Click += new System.EventHandler(this.btnOK_Click);
//MyForm
this.Controls.AddRange(new Control[] { this.txtEnter, this.lblDisplay, this.btnOk});
}
static void Main ()
{
Application.Run(new MyForm());
}
private void btnOk_Click(object sender, System.EventArgs e)
{
lblDisplay.Text = txtEnter.Text + "\n" + lblDisplay.Text;
}
}
}
But I am getting error The type or namespace name 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference?) (CS0234)
Any help is greatly appreciated. Thanks
|
|
|
|
|
I think the clue is in the error message:
ash poxon wrote: are you missing an assembly reference?
Do you have the correct set of assemblies in your project's References? If you created a Windows Forms application project then Visual Studio should have set this up for you. But you may have accidentally deleted the reference.
Right click the References section in the Solution Explorer for your project, then "Add Reference" and then pick from the first tab the assembly called (I think) System.Windows.Forms. If that doesn't exist, open a second instance of VS and create a blank Windows Forms assembly and see what its references are.
|
|
|
|
|
Hi,
Thanks for the reply. I have using SharpDevelop application, and yes it does have the System reference in. I think that maybe I need to use Visual Studio and then it would be easier. you agree??
|
|
|
|
|
ash poxon wrote: yes it does have the System reference in
It's system.windows.forms you need as well. Check for that.
ash poxon wrote: maybe I need to use Visual Studio and then it would be easier. you agree??
Visual Studio does help with some stuff, (Like the LINQ and WPF designers are useful if you do that kind of work, which sharp develop doesn't have) but to be honest, the error message in this case is coming from the compiler so is exactly the same as what you would get with VS.
I've used sharp develop in the past and found it generally fine, just not as polished as VS.
You can get express versions of VS 2008 for free. just google it.
Simon
|
|
|
|
|
brilliant. thanks for that. will give that a try. much appreciated
|
|
|
|