|
There are following classes:
public class X
{
Int32[] a;
public List<Int32> xxx()
{ ... }
}
public class Y
{
List<Int32> a;
public List<Int32> xxx()
{ ... }
}
What I am trying to do is to find a generic way to make the class of similar descent:
public class GenericClass<T> where T : IEnumerable
{
T a;
public List</*Type of the elements in the IEnumerable T*/> xxx()
{ .... }
}
No ideas come to my head. Maybe some will come to yours'? I understand that the problem is that IEnumerable is not generic but maybe there will be any clever solutions
|
|
|
|
|
public class Foo<T> : IEnumerable<T> {
private List<T> someList;
IEnumerator<T> IEnumerable<T>.GetEnumerator();
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator();
}
|
|
|
|
|
I don't know if I understand your problem, but if I'm correct, you should do
public class GenericClass<T>
{
T a;
public List<T> xxx()
{ .... }
}
If it's not what you want, write about your problem in more details.
Don't forget to rate answer, that helped you. It will allow other people find their answers faster.
|
|
|
|
|
You see, if I instantiate this class like this:
new GenericClass<Int32[]>(); ,
then what xxx() returns is List<Int32[]>, although it should return List<Int32>.
Now, if I instantiate the class this way:
new GenericClass<List<Int32>>(); ,
then xxx() will return List<List<Int32>>, but it should also return List<Int32>.
That is why I think that IEnumerable is the way to go for T.
I am starting to think that my idea is conceptually wrong, since I cannot think of anything that would work.
|
|
|
|
|
Your problem is you need T to be the type of element, not a collection of so your IEnumerable idea isn't going to work.
I think you need something like this:
public class GenericClass<T>
{
private List<T> a = null;
public GenericClass(IEnumerable<T> items)
{
if (items != null)
a = new List<T>(items);
}
public List<T> Xxx()
{
return a;
}
}
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Yes, that's what I needed! Simple and elegant. Thank you!
|
|
|
|
|
You're welcome
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Hi!!
Can we make a program which can access the display of a pc from another... just see the desktop(not manipulate it)...
|
|
|
|
|
It's the same as doing it with the manipulation capability. You need to have 2 apps. One running on your monitor machine that shows you what's on the remote desktop and an app running on the remote desktop that puts the screen view together and sends it to your monitoring workstation. Google for "C# VNC" and you'll find examples and libraries.
|
|
|
|
|
Hi!!
M back...
i really need to understand the concept of data recovery...
can we make any program which can do data recovery using C#???
Thanks...
|
|
|
|
|
Concept of data recovery is hard to explain here. In short for writing a sw in c#
you have to wrap low level API's. Not directly possible.
Ahsan Ullah
Senior Software Engineer
MCTS 2.0
|
|
|
|
|
|
What you do and how you write it depends on exactly what you're trying to recover and the device you're trying to recover it from as well as the condition that it's in. You haven't specified what you mean by "data recovery", therefore, it's impossible to tell you what you have to do or if it's even possible to write in C#.
|
|
|
|
|
I want to know if a can recover deleted data from a IDE/SATA HDD, using a c# program....
Do i need to know abt ASM to do it???
often an corrupt hdd is sent for replacement, n the data is lost... cant we make any program or such thing which can recover data from a drive to another(good ) drive...
|
|
|
|
|
You don't need ASM to do it. You just need to have a VERY GOOD knowledge of how the internals of NTFS works, how files are actually deleted, how a disk is organized, and how to read wirte secotrs on the disk.
|
|
|
|
|
Hi,
I've a context menu with two levels. I would like to disable selection in second level. To describe in detail,
level-1->Level-2
AAAAAAA->aa1
aa2
aa3
BBBBBBB->bb1
bb2
bb3
If I select items(AAAAAAA,BBBBBBB) in Level 1, level-2 items gets pop-up. I should disable the selection in Level-2. Please let me know how to achieve this. Thanks in advance.
|
|
|
|
|
|
Wouldn't you use the Enabled property on your sub items to achieve this behavior?
|
|
|
|
|
I am working on C# windows application. and i have a problem in
How can i make my project to run for some speacific period of time.
I mean to say that if any one lounch a software then they provide every one the trial version of their software. Like that Is it is possible to make some small project to run for time limit for one month. if yes please tell me how to do it.
support123
Thank u in advance
|
|
|
|
|
Start here: SmartAssembly™[^].
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
i have created an application in C# which in working fine on local machince(XP)
but when i install that program on network it is unable to conect to database
through error
System.NullReferenceException: Object reference not set to an instance of an object.
at QualiChem.PartyDetails.PartyDetails_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
ans so on
i am working in a network of 5 pc interconnected all pc having windows Xp
what should i do.
plz help
|
|
|
|
|
It seems to be permission issue.
can you post the source code.
____________________________
Ghazanffer Javaid
Software Engineer
|
|
|
|
|
Check the connection string.
If SQL Server, check the SQL Server Browser service.
Check the firewall.
If all else fails, use a Web Service.
|
|
|
|
|
Do a visio connection function. Also on display in visio drawing.
I use a common way of drawing. But in drawing on don't show. Please help...
Drawing area: is a AxDrawingControl controls.
|
|
|
|
|
What is the problem to run in windows 7 64 bit C# application (compiled on Vista 32 bit VS2008 .NET 3.5) which uses PInvoke to run native function from 32 bit Dll.
Exception is System.BadImageFormatException Attempt to load application having bad format (HRESULT: 0x8007000B)
Чесноков
|
|
|
|