|
Well, in your example, the compiler will map to double, and that will break the T:IEnumerable constraint. I guess you simply want the first parameter to be enumerable, in which case,
static public void ToFile(T vec,string name) where T : IEnumerable
{}
will work. Or, if you want to ensure that the caller passes an array of T, you could do away with the constraint, arrays are always enumerable.
|
|
|
|
|
I need to use the code like:
int[] vec1 = ...
double[] vec2 = ...
etc...
ToFile(vec1, "file1.txt");
ToFile(vec2, "file2.txt");
If you remove 'where T : IEnumerable' the foreach statement will not compile, if you keep 'where ...' the ToFile(vec, "filename") will not compile
Would you provide here your modification of ToFile() that compiles along with its invocation with vec1, vec2, etc...
chesnokov
|
|
|
|
|
Huh? Did you actually try removing the constraint? This code compiles fine on VS 2005.
static void ToFile<T>(T[] t, string name)
{
foreach (T val in t)
{
}
}
static void Main()
{
int[] intArray = { };
double[] dArray = { };
ToFile(intArray, "a");
ToFile(dArray, "a");
}
|
|
|
|
|
I am using Outlook 2003 and i want to make my own add in components to Outlook. So in my application, when i click a button, I want to be able to display the outlook address book and be able to select the contacts from the Address book and populate those selected names in my add in component.
How do I achieve the same?
Thank you
|
|
|
|
|
Hi All,
There is the requirement to read Excel file and store data in a datatable for my web project. I am using C# language.
My code is written below
String connString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + excelFile + ";Extended Properties=Excel 8.0;";
objConn = new OleDbConnection(connString);
objConn.Open();
OleDbCommand objCmdSelect = new OleDbCommand("SELECT * FROM [" + excelSheetName.Trim() + "]", objConn);
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
objAdapter1.SelectCommand = objCmdSelect;
objAdapter1.Fill(dt);
The above code returns data to a data table, but the problem is to read formated Excel sheet. Suppose there is a formula field, it doesn't store the actual value. It stores some different value.
What other method to read the excel file? I am not using COM component of Excel to read as it is a web project. There may be a security problem after deployment.
Thanks in Advance.
|
|
|
|
|
Please don't cross post. It's rude
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi friends I want to create a oracle Stored Procedure that stores data in table Employee_Info which is in a dataBase that is named Garmrnts. But I d not know how to create a stored procedure that stores data. Oh! I want to access those procedure using C# & Oracleconnection. Can any one tell me how can I do that? Plz It will really help me a lot.
|
|
|
|
|
You may want to look around on Oracle's site or ask this in the SQL forum.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
|
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
I created a setup for my small application using the click once deployment method.But I also want to execute another *.exe file in setup. i.e. I want to execute another *.exe file after the setup has been completed.
Do you guys know how to do it?
|
|
|
|
|
Don't cross post the same question in multiple forums. It make's collaboration on an answer just about impossible.
|
|
|
|
|
|
You shouldn't cross post messages. It's considered rude - see forum guideline no.1.
Choose the most appropriate forum for your question and post there only. As this is an ASP.NET question, the ASP.NET forum is more appropriate.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi!
I created a new Windows Service in C# and want to set a Service Dependency.
Did it like this:
ServiceInstaller si = new ServiceInstaller();<br />
si.ServicesDependedOn = new string[] { "DependingOnThisService" };<br />
this.Installers.Add(si);<br />
Everything works fine. My Problem right now is, that I want to set this Dependency only in fact of a special "flag" in the app.config - file.
But I am not able to read from the app.config - file in the ( from System.Configuration.Install.Installer inherited) class.
I neither get an exception nor a result from the config - file (always get an empty string).
So is there a possibility to read from the app.config in this class or, if not, what is the best alternative to do this?
Hope anybody can help me!
tia
|
|
|
|
|
How can I get yes/no/cancel option from javascript.
I know a option "Confirm" but this code has two option (OK/Cancel)
|
|
|
|
|
A C# forum isn't really the best place to ask (!) but here you go[^].
|
|
|
|
|
|
I am using VS 2003 with 1.1 of the framework. (No hope of getting an upgrade )
Scenario
I am using a textbox which allows a user to input text in order to filter a list. I am using the KeyPress event for the control to save the user from having to click a separate button.
Problem
The event doesn't fire sometimes. The odd time another control (e.g. a button ) gains focus and fires it's Click event.
I have tried searching this site as well as Google to no avail.
Has anyone encountered this type of problem?
|
|
|
|
|
Other controls should only get activated if they have some kind of shortcut via alt or if they are the accept/cancel buttons (enter / esc). It might be worth checking the keypreview property of your form is set to false.
|
|
|
|
|
You might want to make sure the Form's KeyPreview Property is set to true. Getting the property information from the object browser for the property:
<quote>Gets or sets a value indicating whether the form will receive key events before the event is passed to the control that has focus.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Hi All,
I'm fairly new to C# so somewhat clueless. I'm writing an error handler class library which will receive exceptions thrown and can be configured to display and/or log the exception.
In order to display, I'm trying to use the MessageBox class so I've included a reference to System.Windows.Forms. I also added a using statement for System.Windows.Forms. When I compile, I get an error "The type or namespace name 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference?)". I'm guessing that the problem has something to do with the fact that I'm working with a class library and perhaps .NET uses a different System class for class libraries. I've tried this with VS 2005 and SharpDeveloper and both give exactly the same error.
Is there a genius out there with a solution?
Thanks,
Steve
|
|
|
|
|
Hi,
to use the many classes .NET provides, you typically need to do two things:
1. add a reference, using the Solution Pane, right click on the project, choose Add Reference,
and select (in your case: System.Windows.Forms);
2. add a using statement (using System.Windows.Forms). You will notice Intellisense works
for you while you type this provided you finished step 1 first.
Some of these may happen automatically, depending on the project type you selected,
but none so for a class library.
modified on Friday, January 11, 2008 12:28:45 PM
|
|
|
|
|
Please read my original message. You'll see that I did add a reference and a using statement.
|
|
|
|
|
I think I told you everything there is to do to get it right.
Does Intellisense show Windows when you have entered "using System."?
Does Intellisense show Forms when you have entered "using System.Windows."?
Can you show some code, up to the line that causes the error?
general suggestion: tell the Visual editor to always show line numbers (see menu
Tools/Options/Text Editor/...), then debug using the line numbers the compile- or
run-time messages provide.
|
|
|
|