|
yaa , i will try it ..
anyway ..
anyone have idea how can i pick the value that i had insert to a table ..
i use the code that i show in the first message of this post in VB.NET and it work's fine .
i don't know why in CS it don't work ...
|
|
|
|
|
Hello,
how can I use a value type in a generic method constraint? Is it at all possible?
Obviously,
public static T1 GenericMethod<T1>(T1 input) where T1: int, double, decimal
won't work.
Thanks,
Michal
|
|
|
|
|
public static T1 GenericMethod(T1 input)
where T1 : struct
{
}
|
|
|
|
|
Ok, thanks, but I assume that all value types are comparable, however the following example code doesn't compile with "where T1: struct":
public static T1 GenericMethod<T1>(T1 value1, T1 value2) where T1: struct
{
if (value1 > value2)
{
return value1;
}
return value2;
}
So there must be some other way to restrict T1 just to value types.
Thanks,
Michal
|
|
|
|
|
How about this?
public static T1 GenericMethod<T1>(IComparable<T1> value, IComparable<T1> value2)
where T1 : struct
{
}
|
|
|
|
|
Doesn't work, unfortunately:
public static T1 GenericMethod<T1>(IComparable<T1> value1, IComparable<T1> value2) where T1 : struct
{
if (value1 > value2)
{
return value1;
}
return value2;
}
is producing this error:
Operator '>' cannot be applied to operands of type 'System.IComparable<T1>' and 'System.IComparable<T1>'
It doesn't help to use "where T1: struct, IComparable" neither.
Michal
|
|
|
|
|
Yes, don't use the greater-than or less-than operator to compare the values, since not all IComparable objects implement those operator methods (seems silly they don't, IMO). Instead, use this:
if(value1.CompareTo(value2) > 0)
{
return value1;
}
return value2;
|
|
|
|
|
Thanks for the hint!
The final compilable notation would be this:
public static T1 GenericMethod<T1>(IComparable<T1> value1, IComparable<T1> value2) where T1 : struct
{
if (value1.CompareTo((T1)value2) > 0)
{
return (T1)value1;
}
return (T1)value2;
}
Michal
|
|
|
|
|
How do i capture the events in the datagrid header text?
actually i have to sort the datagrid column when an image is click on the header of the datagrid column?
people laugh at me because they say im different and I laugh at them because they are all the same.
|
|
|
|
|
sundar156 wrote: How do i capture the events in the datagrid header text?
Handle the ColumnHeaderMouseClick event.
/ravi
|
|
|
|
|
Hello everyone:
I've created a TxtBox with vertibal bar enable and Button. When user click on Button and and browse to select any file, that file would get store on that txtbox.
I dont know how to started. Could someone please provide some sample code that I could work with?
Thanks,
Eyungwa
-- modified at 13:18 Wednesday 7th February, 2007
|
|
|
|
|
myTextBox.Text = File.ReadAllText ("C:\\myfile.txt"); /ravi
|
|
|
|
|
I am working with large bitmap files. In general centering on the mouse click does not cause any problems. If I am zoomed out(max 1/4 of original size) and then zoom in (max double original size) quickly and try to center on the mouse click I get an InvaidOperationException unhandled BufferedGraphicsContext cannot be disposed of because a buffer operation is currently in progress.
I have looked at BufferedGraphicsContext and tried setstyle with AllPaintingInWmPaint, OptimizedDoubleBuffer, UserPaint set to true but still get the same error. Could anyone point me the direction I need to go to correct this problem or what kind of try/catch I need to implement?
Thanks Jim
|
|
|
|
|
public delegate int TestDelegate(int c,int d);
A delegate can reference a method only if the signature of the method exactly matches the signature specified by the delegate type.
Mainly a delegate needs a signature.i.e..return type and input parameter datatype.
Why i need to say the variable name with the datatype "int C & int D". Is MS is using this "int c & int D" internally.
Suresh.P.S
|
|
|
|
|
I agree, technically there is no need for variable names here; but C# expects them,
and you can benefit in readability, especially if you also add /// comments for
Intellisense.
Luc Pattyn
|
|
|
|
|
Hi guys, I wanted to know how can i build a voice application through vs2005 if possible in C#. I had IBM Toolkit 5.1, a very old version that requires VXML language.
I am not sure how to get start working around in VS and how can I set my platform setup after having installed vs2005.
I shall be thankful
Thanks
|
|
|
|
|
netJP12L wrote: how can i build a voice application
What do you mean by "voice application"? TTS? Recognition? Both?
You might find this[^] to be a useful read. And this CP article[^] and this[^] should help you get started with TTS.
/ravi
|
|
|
|
|
When a tree node is pressed with a right click it highlights it and then selects back the node that was selected before, how can i make the node be selected on right click as well?
|
|
|
|
|
In the NodeMouseClick event:
treeview.SelectedNode = treeview.GetNodeAt(e.Location);
|
|
|
|
|
Worked like a charm :P
Thanks alot
|
|
|
|
|
|
I want to show only some collumns from a XML file.
I have 3 collums: IDName - Name - Age
I want that the datagrid show only Name
I tried:
dataGrid1.DataSource = ds.Tables[1].Columns["Name"];
but it doesn´t work... can you help me?
ThankS!
|
|
|
|
|
Use a DataGridView and set the DataGridViewColumn.Visible property to false for the particular columns in the Columns collection.
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Hi
I have created a control the is transparent. When this is placed a normal form with a picture it works fine, but when it is on a control container where I draw the background as a gradient using the drawing tool, the transparency only shows the background colour of the control, and doesnt work over the image/gradient that i've drawn.
How do I get the background to draw first, or how do I get the control to look at what is painted on its container.
Thanks in advance
Deano
www.deanpugh.com
|
|
|
|
|
In visual studio 2005 within an asp.net project you can bring up the style builder by placing an html input control on a web page and going to style in the property grid. I would like to use this editor in a windows C# project on my property grid.
How do I make the following show that editor in my class that is the "SelectedObject" in the property grid?
class mySelectedObject
{
private string mStyle;
/// [I know I need to put something here in the brackets]
public string Style
{
get { return mStyle; }
set { mStyle = value; }
}
}
Thanks
Chris
|
|
|
|