|
This is not the best place to ask ASP.NET Questions. There is a seperate forum for it.
Either you love IT or leave IT...
|
|
|
|
|
I cannot get generics to return a type that it does not know is correct.
I have a collection of general objects each with a sorted keyfield ID
cTypeA 2
cTypeB 3
cTypeA 7
cTypeA 9
cTypeB 12
in one ArrayList, all of which derive from cType.
I want to create a separate list of ID references using generics, but which returns the actual objects in an indexer. That way I am assured of type safety when using the object (displaying in a listview say) rather than casting at the end use point:
public class cList<T>
{
public cList(cIDList UseOwner)
{
Owner = UseOwner;
ListItems = new ArrayList();
}
public T this[int Index]
{
get
{
if ((Index >= 0) && (Index < ListItems.Count))
{ return (T) Owner.GetObject((int)ListItems[Index]);
}
}
}
private cIDList Owner;
private ArrayList ListItems;
}
to implement this
cList<cTypeA> AItem = new cList<cTypeA>(MyIDList);
(assume items added)
cTypeA UseA = AItem[2];
Is there a way to solve this problem? The only way I can see is to do the above without generics, copy and paste then change the return cast type for what I use now, and in the future. Not easily manageable!
Thanks.
|
|
|
|
|
You can use a generic List instead of an untyped ArrayList , then copy the required references in the c'tor. (This assumes you are using .NET 3.5 - and of course your cIDList must be an IEnumerable , i.e. derived from any of the usual .NET collection classes).
Here's what it will look like:
public class cList<T>
{
private readonly List<T> ListItems = new List<T>();
public cList(cIDList UseOwner)
{
if (UseOwner != null)
{
ListItems.AddRange(UseOwner.OfType<T>());
}
}
public T this[int Index]
{
get
{
if ((Index >= 0) && (Index < ListItems.Count))
{
return ListItems[Index];
}
return null;
}
}
}
Regards
Thomas
www.thomas-weller.de
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. Programmer - an organism that turns coffee into software.
modified on Sunday, May 3, 2009 11:35 AM
|
|
|
|
|
You probably need to redesign whatever it is you're trying to do.
Otherwise, try cTypeA UseA = AItem[2] as cTypeA ;
|
|
|
|
|
from where i can download sql database template for visual studio
can any buddy provide link plz
|
|
|
|
|
What (kind of) template are you looking for?
I'm having trouble understanding what it is that you seek, please rephrase the question.
I are troll
|
|
|
|
|
if you go to your solution explorer there is an option "Add new item". then there will be a "Sql DataBase" template. i dont have that n i want that.
thanks
|
|
|
|
|
I guess that the template is installed by SQL Server (Express?). Try downloading/installing that, or repairing the Visual Studio installation itself.
I are troll
|
|
|
|
|
It would appear that you have to Express edition of Visual Studio, which does not come with Database project templates. There is no legal place to download those templates.
|
|
|
|
|
I want to control some hardware by internet. In order to do that I want to use ASP.NET and C# language. Suppose I want to turn on a LED which is placed in a PCB board. That PCB board is connected to a computer which has internet connection. From remote distance I will do some thing so that that LED will be turned on. If any body know some things abut the above meter please inform me as soon as possible.
Rashed
|
|
|
|
|
Are you hoping to become a developer or just spamming the site with a stupid question?
If you are then I suggest you start with something simpler, maybe "hello world" would be a good start. Read, study, try some things and ask specific questions about problems you encounter.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
rashed.info wrote: In order to do that I want to use ASP.NET and C# language.
That means that the computer who has the PCB-card in it needs to be an ASP.NET server
I suggest you browse the Coding 4 Fun[^] blog, it has some hardware-related projects that could get you started.
I are troll
|
|
|
|
|
Hi All
I Install my Windows Project In PC .
In The First Run Of the Application Is Run As Correct Way.
but the secound Run Of the Application The Windows Give Me the Error In Message Box
The Message IS :
Unable to find a version of the runtime to run this application .
and the Caption of a message is
Management.exe .Net FramWork Initailization Error
What Is this Error ??
How I Can Solve It ??
Thanks All
Thaer
modified on Sunday, May 3, 2009 2:46 AM
|
|
|
|
|
|
Usage of this thing
But not that good help
I have all the solutions proposed, but did not change something
We put that question to answer me one of them has been successful with the process and not to provide a teacher how to search
Thanks Mr
Thaer
|
|
|
|
|
HI
when i want to input my equation (ex: ((Math.Pow(x,5)) + x - 1) ) from textbox to function this erro
appear . format exeption was unhandeld .
my code is here
public double func(double x)
{
return (double.Parse((txtEq.Text)));
}
i want to user can input equation from textbox.
Thank u so much
|
|
|
|
|
Just typing in an equation and expecting the Double parser to understand and evaluate it, isn't going to work. You have to write your own equation parser and evaluate it yourself. There is nothing in the .NET Framework that will do this for you. Google for "Reverse Polish Notation" for information on one algorithm that can help you do this.
|
|
|
|
|
|
Hey all,
I was wondering if anybody else is experiencing problems trying to view any Microsoft websites such as MSDN.com, Hotmail.com, Microsoft.com or any other Microsoft website? For a week now I have been trying to get on to the MSDN website to check out some things but it never loads, my system has been scanned several times with a few different programs, and I know it isn't my firewall or my Internet because every other website works perfectly... Is Microsoft experiencing any problems? Thanks all
jay
foreach( inch on Jason )
{
Girlfriend.IsHappier();
}
|
|
|
|
|
They all work fine for me. Try clearing the browser cache.
|
|
|
|
|
jas0n23 wrote: Is Microsoft experiencing any problems?
Probably, but as for the MSDN website - it works fine.
|
|
|
|
|
Hi,
I would like to develop a VS 2005 Add-in that provides a new document editor for a custom file type of mine. Could someone point me at some documentation or a tutorial that would help me to achieve this because I am currently having difficulty finding any.
Thanks,
Steve
|
|
|
|
|
I have a main form that has a panel control and the user can select which of
the two "child" forms to display in that panel control from a menu selection.
Depending on which form is displayed in the panel, the app will display data from a Tektronix TDS-2024B scope or other data from an external
DAQ (Data Acquisition module). The current code shows the forms without a problem. But if I switch between the two forms; data is no longer updated in
the textboxes when I run a data capture routine for one form or the other.
However, if I do not switch from one form display to the other after firing up
the app, data is updated correctly.
Example code for one of the form displays in the panel is:
private void ScopeCapture_Click(object sender, EventArgs e)
{
frmTDS2024BScopeCapture TDS = new frmTDS2024BScopeCapture();
TDS.MdiParent = this;
TDS.TopLevel = false;
TDS.Dock = DockStyle.Fill;
//Container
this.panel1.Controls.Clear();
this.panel1.Controls.Add(TDS);
TDS.Show();
currentTest = "TDS";
////TDS.tbFreq.Text = "4578223"; //test only
}
The code for the second form is identical, except for the form reference.
Could I be having a problem with the Z-order of the panel when switching from one form to the other?
Hope someone has run into this before and can shed some light on the issue. I tried not to clutter this post with too many details.
If further code is required, please advise.
Thanks in advance,
Steve.
P.S. I have Googled, searched forums, etc till I'm blue in this face with this one.
|
|
|
|
|
The only thing that seems 'odd' to me at first glance is the line TDS.MdiParent = this; . From the code you have posted I can see no need for this. By adding TDS to the panel, you are not allowing the Main Form to operate properly as an MDI Parent, and I would suggest that you at least try running your Application with the line commented out and see if it runs OK.
I do not know if this will solve the problem entirely, but that line is certainly not helping.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thank you Henry for the reply.
I will try what you recommend.
I don't see many comments on the Web or MicroSoft on how to show forms in a
panel control. Could be, I'm trying something that has potential problems
that are not documented anywhere. As I mentioned, the forms show up in the panel control just fine. After switching between one and the other, the textboxes in those forms are no longer updated when expected.
I'm using a PXI chassis from National Instruments to capture data from several
voltage/current sources and as well as getting scope captures via a USB port from a Tektronix scope.
Best Regards,
Steve.
BTW, I don't read medical books. Former medical student here...
Then I got hooked on Math and programming and now this problem!
|
|
|
|