instantiate

C# instantiate in foreach loop?

Possible Duplicate: Loops and Garbage Collection foreach (ObjectTypeA typea in ObjectTypeACollection) { var objectTypeAProcessor= new objectTypeAProcessor(); objectTypeAProcessor.Process(typea); } I found the above similar code where a collection of objects was being processed at the BLL and the DAL processor was called.Will ...

Create an instance of an ASMX stub object from a real object

I have an ASMX web service that exposes several objects. I have a real instance of that object, and I would like to instantiate a stub object that is populated from it. Clearly there is such functionality already, because when the web service returns a value it is creating the stub and populating it. I just need to do the same thing man...

WPF Instantiate User control programmatically to render it as PNG

hey all, I want to instantiate a user control programmatically in a DLL to save it afterwards as PNG file. This is generally no problem with PngBitmapEncoder and RenderTargetBitmap. This are my questions: How do I instantiate the control? Simply with the new-operator? Do I have to instantiate it in an seperate thread? How do I force ...

How does one instantiate an array of maps in Java?

I can declare an array of maps using generics to specify the map type: private Map<String, Integer>[] myMaps; However, I can't figure out how to instantiate it properly: myMaps = new HashMap<String, Integer>[count]; // gives "generic array creation" error myMaps = new HashMap[count]; // gives an "unchecked or unsafe operation" warnin...

php - any way to access properties of an already instantiated class from another script without reinstantiating it?

Hello guys. I have page main.html which is a client application for a specific server. The main.php is an window with three frames. main.html <frameset frameborder=no border=0> <frame name='top1' src='top1.php' frameborder=no scrolling=no> <frame name='top2' src='top2.php' frameborder=no scrolling=no> <frame name='firstpage...

Instantiating objects and object members

For some reason the following doesn't crash like my program does, but I'm pretty sure it's similar in design. For one, the output's not correct. It outputs something similar to: 0x537ff4 5471612 While the main program outputs (nil) for the pointer address. The key to the problem might be display_ in Drv. Here's the code: #include <...

PHP: How to instantiate a class with arguments from within another class

Hello All, I am in a situations where i need to instantiate a class with arguments from within an instance of another class. Here is the prototype: //test.php class test { function __construct($a, $b, $c) { echo $a . '<br />'; echo $b . '<br />'; echo $c . '<br />'; } } Now, i need to instantiate above class using below cla...

How can I instantiate WPF elements via their type when they have StaticResources?

I need to instantiate WPF types (say, a UserControl or a Page) via reflection for a designer. The problem I'm having is that when I attempt to instantiate these using Activator.CreateInstance I get a TargetInvocationException which wraps, in the end, an exception thrown by the StaticResource markup extension. Clarification: The types ...

PHP: Instantiate class by reference?

I'm converting some old PHP 4.x code for PHP 5.3. I've come across the following, and I'm not sure what it does. $variable =& new ClassName(); What is the difference between that, and: $variable = new ClassName(); ...

Instantiate Generic Type in C# class

Pretty basic question in C#, class Data<T> { T obj; public Data() { // Allocate to obj from T here // Some Activator.CreateInstance() method ? obj = ??? } } Not sure how to do this ? Thank you for any assistance. ...

Cost of multiple instantiations

While working in a project today, I came across the following code: pcShowByCategory.Controls.Add(new LiteralControl("<div id='lblDivP'>")); pcShowByCategory.Controls.Add(new LiteralControl("<table width=100%><tr><td colspan='2' align ='left'>")); pcShowByCategory.Controls.Add(lblTitle); pcShowByCategory.Controls.Add(new LiteralControl(...

Confusing with memory allocation of array in Java

I get annoying to comprehend memory allocation of array in Java,could your guys give me some clarification about this.Following is an example that i want you to give me the result of how many object get instantiated for each statement. String s1[] = {"12","saf"}; int s2[] = {1,2}; Object s3[] = new Object[2]; String s4[][] = {{"12","...

Silverlight object not created on page from time to time

Hello everybody, I have a problem I put several silverlight objects on the page with object tag Page is loaded in IE perfect, but Opera/Google Chrome doesn't load some of the objects from time to time. These browsers demonstrate "Install Microsoft Silverlight" image instead of objects and no errors on the page. Please, who has face...

How do I use a .NET class in VBA? Syntax help!

ok I have couple of .NET classes that I want to use in VBA. So I must register them through COM and all that. I think I have the COM registration figured out (finally) but now I need help with the syntax of how to create the objects. Here is some pseudo code showing what I am trying to do. EDIT: Changed Attached Objects to return an Arr...

Simple way to decrease values without making a new attribute?

I'm making a program where you're firing a 'blaster', and I have 5 ammo. I'm blasting an alien who has 5 health. At the end I instantiate the player and make him blast 6 times to check that the program works correctly. But the way I've done it makes it so that the amount won't decrease. Is there an easy fix to this, or do I just have to ...

how to instantiate template of template

hello I have template that looks like this: 100 template<size_t A0, size_t A1, size_t A2, size_t A3> 101 struct mask { 103 template<size_t B0, size_t B1, size_t B2, size_t B3> 104 struct compare { 105 static const bool value = (A0 == B0 && A1 == B1 && A2 == B2 && A3 == B3); 106 }; 107 }; ... 120 const typename boost...

Insane SmartGWT + GWT situation... Error on instantiating ListGridRecord?

Hi all, I am asking this here in the hope that someone has maybe come across this situation too... I have posted this on the SmartGWT forum: I am having an issue when trying to instantiate a ListGridRecord object on my server side. I am using the ListGrid on the client side, I want to use GWT's RPC to pass back an array of ListGridReco...

adding stock data to amibroker using c#

hello, I have had a hard time getting and answer to this and i would really , really appreciate some help on this. i have been on this for over 2 weeks without headway. i want to use c# to add a line of stock data to amibroker but i just cant find a CLEAR response on how to instantiate it in C#. In VB , I would do it something like; ...

Programmatically choose the class to be instantiate

I am currently playing around with VB.Net using Visual Studio 2010 (.Net 4.0) and I need your help to create a collection class (let's call it 'cl_MyCollection') with a constructor that accepts two arguements: 1) An "SqlDataReader" object 2) Some means of pointing to a custom class I have created The scenario is; I have five database ...

Java Instantiate Abstract Class or Partially Implemented Interface

I have an interface that has about 20 methods (huge). I want to create a single instance for testing purposes, but I only need to override one method. What's a good way to get an instance of this class with the overridden method without having to define the whole class with a tone of "//TODO: implement this" methods. Mocking frameworks...