.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Class which contains an array of objects of type "Class2"

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net


1  Partial Class _Default
2  Inherits System.Web.UI.Page

3 Public Function Ohjoy(ByVal X As Integer) As Integer
4 Dim theClass As New Class1 '= New Class1()
5    theClass.ReSize(0)
6    theClass.myBaby(0).GetName(0) = "Hello" 'Property Chars is read only'
7    Return 1
8 End Function
I have a first class named "Class1". I have a second class named "Class2" Class2, is a member of class 1,
and is implemented as an array of objects of type Class 2.

If I try and call the Accessor GetName() my hard coded value "Hello" in my accessor is not returned? Only
an alpha character like "T"

Also if I try and assigne a value using the setter GetName() it does not work, and the compiler gives me
an error message "property Chars is ReadOnly? Does anyone know what is wrong in my code? Line 6 above


Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
End Class

Public Class Class1
    Dim bs As Integer
    Public myBaby() As Class2
    Public myB As Class2
    Public Function ReSize(By

View Complete Post

More Related Resource Links

How to make an array of class objects in Visual Basic

How can I make an array of objects in VB.net. Here is the requirement.Basically I have a class named hotel. I need to dynamically add customersto the hotel class using the Customer class. So basically if in the Hotelclass I can have an array of Customer objects that would be great. How can I do this in VB .net ? Public Class Hotel  ' I need an array of Customer objects. objCustomers End Class   Public Class Customer Private custId As Integer Private custName As String Private custAddress As String Private custCity As StringEnd Class Pseudo code:  Dim Hilton As Hotel = new Hotel()   Hilton.objCustomers(5) ' Declare an array of 5 customer objects   Hilton.objCustomers(0).CustId=1  Hilton.objCustomers(0).CustName="JoJo Smith"  Hilton.objCustomers(0).custAddress="122 Emory Lane"  Hilton.custCity="Merry More"  .  .  .  Hilton.objCustomers(4).CustId=1  Hilton.objCustomers(4).CustName="Ice Baby"  Hilton.objCustomers(4).custAddress="66 Domino Drive"  Hilton.custCity="Miami"    End While

How to create an array of VB.net objects from a VB .net class


I need to create an array of a class type. Populate the values in the class and then pass
the array to a subroutine. I havent figured out how to do this properly as I get a null
reference exception. Can someone show me how to create/instantiate the array of objects?
Here is a simple example with only one property named "_momentum". My actuall class has about
10 properties/variables in actuality

Public Class Torsion

 Dim _momentum As integer

 Public Property Momentum
            Return _momentum
    End Get
    Set(ByVal As Integer)
      _momentum = value
End Propterty

' Later in the code I try to create and object of the class

Dim x(0) As Torsion

[RESOLVED] Cannot deserialize an array of objects (of variable type)


Hi helpful folks and gurus

I have been developing an application which uses a derived class inherited from TreeView, with the aim of putting custom objects on the nodes.  The method I have been using is to have a variable array against the node (of type object) which contains variables in custom classes to contain each of the variables associated with the node.

The two problems I had to overcome were, how to serialize a TreeView, and how to serialize an array of objects (of variable type).  Good thing is I overcame both of these with some work of some other folks (and 3 days of my own work).

TreeView: http://www.codeproject.com/KB/vb/TreeViewDataAccess.aspx?display=Print

Object Array (NOT of variable type). adapted to variable type: http://www.codeproject.com/KB/XML/xmlserializerforunknown.aspx

Serialization works a charm..  Deserialization naddah..  Can find no sufficent documentation for me to debug and work on manual deserialization (of only one variable, the variable array of objects).  All others are handled by the regular deserializer.

Effectively the xmlserializerforunknown URL provided a solution which manually handles both the type handling and the handling of the object array.

The main error I'm having lies in the ReadXml, function.  I just can't align the xml with the code.


"The base class includes the field 'WebUserControl1', but its type (common_WebUserControl) is not


I tried to convert a project from ASP.NET 1.1 to 2.0 and found one big problem which stops the whole process.

An .aspx page from the subfolder "admin" includes a user control from the subfolder "common". Both subfolders ("admin" and "common" are in the root).

- admin
-- aspx page
- common
-- user control

The page works well when started from Visual Studio, but when the project is precompiled for deployment, the next error occurs:

"The base class includes the field 'WebUserControl1', but its type (common_WebUserControl) is not compatible with the type of control (ASP.common_webusercontrol_ascx)"

I tried to use "Reference" in the .aspx page, but that doesn't work.

Does anybody know any workaround for this?

The type '' exists in both '' and ''

For some reason though it appears that one of my class files (_common.cs - in the App_Code directory) is being included in the WAP .dll file as well as when it compiles the App_Code at runtime.error CS0433: The type 'inlinehockey._common' exists in both 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\25321638\9b5c4b00\assembly\dl3\3657f4e6\cd91aef5_4d5cc601\inlinehockey.DLL' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\25321638\9b5c4b00\App_Code.xad_ajc1.dll'  The error was not knowing what dll to use for the type when you get the CS0433 error.How can I get round this error?ThanksJeremy Thakewww.made4the.net

Calling a method with a class object as parameter data type.

   [WebMethod]    public string GetInfo(Customer inCust)    {        // Code in here    } I have a web service that resides on a remote server. I want to call a public method of theweb service named  "GetInfo". The method is shown above. The web service method expects a class object oftype "Customer". What I did to create a Customer object was to define in my asp.net project my own class named "Customer" which is exactlythe same as the class that belongs to the web service project on the remote server. I then created an instance of Customerand tried to call the web service passing in an object of type customer : my.Service ws = new my.Service(); // Get web service connectionCustomer aCustomer = new Customer();aCustomer.Initialize();ws.GetInfo(aCustomer) // call web service passing in a Customer object The problem is that the compiler gives me the following error: Value of type '_Default.Customer' cannot be converted to 'ws.Class1'. Here Default is refering to my Default.aspx.cs code. Why is this? Do I need to Cast my "aCustomer" class object to a type ofws.Customer ? How do I do that?

Sending Array of Custom Class over WCF Problem

I have been attempting to convert some service calls that returned a DataSet into something more lightweight. For instance, I am converting: [OperationContract] public DataSet GetCommittees(); into: [OperationContract] public List<VolunteerCommittee> GetCommittees(); where committee is defined as: [DataContract] public class VolunteerCommittee { [DataMember] public int Id { get; set; } [DataMember] public String Name { get; set; } } I copied the structure of the data contract and the operation contract right from an example in a book I bought on WCF. The author mentioned that the List<VolunteerCommittee> would get converted into an array over the wire, so the client's operation contract looks like: [OperationContract] public VolunteerCommittee[] GetCommittees(); My problem: When the service is called, an empty array is returned every time. When I put trace statements in, I see an array of 48 VolunteerCommittees leaving the server. I've done some reading on the problem and tried a number of suggestions, such as using the XmlSerializer attribute, including a certain namespace as a [return:] on the server's contract, changing the type of binding (it's using wsHttpBinding... I tried basicHttpBinding) and turning off MTOM in the behavior, but none of these changed the empty result of the call. At this point, I'm hoping someone can shine some light on

Linq Where Clause (on class that has an [array])

Hi There.I have the following query that return the below class type.var results = from r in _returnListOfItem(XMLFile)                       select r;   // Image BluePrint    public class OneImageBluePrint    {        public int UniqueID { get; set; }        public string VirtualFilePath { get; set; }        public string URL { get; set; }        public string Title { get; set; }        public string Subject { get; set; }        public string[] Keywords { get; set; }        public string Author { get; set; }        public string Collection { get; set; }        public string DateAdded { get; set; }        public string Copyright { get; set; }        public int PriceRange { get; set; }        public string LocationPlace { get; set; }        public string LocationCity { get; set; } &nbs

array of objects

Hi , i want to store objects in a array, that is array of objects    

spmetal generated class and content type (for page layout) retrieve problem


I'm working with a console application to generate my sites and subsites (hierarchy). And i've got a problem with a generated spmetal class.


this doesn't work:


static void Main(string[] args)


            string SITE = string.Concat("http://"Environment.MachineName);         



class contains non-dependency-property data members that are DependencyObject objects, you must also


I was reading the article Freezable Objects Overviewand came acrosee the statement

"If  your class contains non-dependency-property data members that are DependencyObject objects, you must also call the OnFreezablePropertyChanged method each time you change on of their values, even if you're setting the member to null. "

I quite do not understand the part about non-dependency-property data members that are DependencyObject objects. Can some one explain exactly what this means? If a data member is derived from the DependencyObject  class how then can the data member be a non dependency property?

I am also trying to locate some source code / project that overrides the OnFreezablePropertyChanged method, and have yet to find any on the interenet.

If anyone know whe

Property Array of other Property Type



I am making use of two property classes, between them one is type is that of other property array type, it has the following code:

public class Entities
        private Property[] employeeInfo;
        public Property[] EmployeeInfo

Inherited Page class type confusion


I have a single top-level window that holds a single object--a Page. I want the main window to resize based on the client area size (i.e., the Page size). I am doing this by having the main window resize property SizeToContent="WidthAndHeight".

My Page definitions:
    public class PageHelper {
        static public PageWelcome oPageWelcome = new PageWelcome();
        static public PageHelp1 oPageHelp1 = new PageHelp1();
        static public PageHelp2 oPageHelp2 = new PageHelp2();

If the user resizes the window, it should be easy enough adjust the size of the content Page (I haven't written the code yet). But what do I do when the user goes to a new page after resizing the window? It seems that I can either (1) resize all the pages when the user resizes the window, even the ones that are not active :(, or (2) I can make sure the new page is the right size when the user tries to go to it. :)  But I am having trouble with the latter approach.

I made my own Navigate function I call ACNavigateToPage which I want to call instead of calling Navigate when the user wants to go to a different page.

    public partial class WindowMain : NavigationWindow {

using UpdateSourceTrigger=Explicit with GetBindingExpression() on class objects with inherited



I have a class that inherits from FrameworkElement and has a mixture of DPs that I've added and the ones inherited e.g. WidthProperty, HeightProperty etc...

I have a UserControl that inherits from my class and has various textboxes in a popup resource like this

<TextBox Text="{Binding Path=Width, UpdateSourceTrigger=Explicit}" />

I've added a click button so that when the user changes one of the textboxes (in the popup), a routedUIcommand will fire (see below).


 public static void OkCommand_Executed(object sender, RoutedEventArgs e)
      MyClass c = (MyClass)sender;

//this seems to work fine because it is implicitly declared in my class
      BindingExpression be = s.GetBindingExpression(MyClass.MyPropertyProperty);
      if (be != null) be.UpdateSource();

//this does not work because the DP is inherited from FrameworkElement. It is returning null.
      BindingExpression be = s.GetBindingExpression(MyClass.WidthProperty);
      if (be != 

Regarding Creating Custom Field type Class Inheriting from IFieldEditor Interface and UserControl C


How to enable the hidden labels On Create Column Page after selecting our Custom Field type before just ckicking OK so that all those labels appear.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend