.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

Using a List(of T) as a "Property" in a class

Posted By:      Posted Date: October 20, 2010    Points: 0   Category :ASP.Net

In my application I have a class called "RCategory" as illustrated here:

Public Class RCategory
    Public Property RCatNum As Integer
    Public Property RAct As Char
    Public Property RMin As Double
    Public Property RMax As Double
    Public Property RTyp As Char 
End Class

I have another class where I want to use a List (of RCategory) as a property, to-wit:

    Public Property RpStrt As Date
    Public Property RpEnd As Date 'Plan Year End
    Public Property RCat As List(Of RCategory)
    Public Property MinFee As Double


I'm trying to add to my list using the following code:

                        For ct As Integer = 1 To 8
                            Dim c As New RCategory With {.RCatNum = ct,
                                                         .RAct = dr("RACT" & ct.ToString).ToString,
                                                         .RTyp = dr("RTYP" & ct.ToString).ToString,
                                                         .RMax = CDbl(dr("RMAX" & ct.ToString))}
                            If ct = 4 Or ct = 5 Then
                                c.RMin = CDbl(dr("RMIN" & ct.ToString))

View Complete Post

More Related Resource Links

abstract away the source of the connection string using a class with a static property.

ASP.NET provides a configuration system we can use to keep our applications flexible at runtime. In this article we will examine some tips and best practices for using the configuration system for the best results.

The element of a web.config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work. The items inside appSettings are items that need to be configurable depending upon the environment, for instance, any database connection strings will change as you move your application from a testing and staging server into production.

Let's abstract away the source of the connection string using a class with a static property.

Get pixel format, raw format, property id list and property items image in VB.net - C#.net.

n this simple article you will learn that how we can get pixel format, raw format, property id list and property items image in VB and C#.net.

Get Pixel Format:

Image consists of pixels to get the format of the pixel we have a property named pixel format. This property returns an enumeration of pixel format. This enumeration tells the pixel format.

To demonstrate make a window application. Drag one button and a picture box on form.

Now write the following code on Button click event:

SelectMethod property missing from DomainDataSource class

I have an issue using WCF RIA with ASP.NET. I can't find the SelectMethod property of the Microsoft.Web.UI.WebControls.DomainDataSource class. What happened to this property? Am I using the wrong class?  I'm using VS2010 with the latest versions of Silverlight 4 Tools and RIA Services Toolkit installed. Any help with this would be greatly appreciated. Cheers, Simon

Can serialize but not deserialize class containing an xs:list attribute using XmlSerializer

I have a simple serializable class along the lines of: [Serializable] [XmlType] public class MyClass { [XmlAttribute("values")] public int[] Values { get; set; } } If I create an instance of this class with Values set to an empty collection the XmlSerializer class produces this output as expected: <?xml version="1.0" encoding="utf-16" ?> <MyClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" values="" /> However, deserializing this exact output throws a System.FormatException: Input string was not in a correct format. Shouldn't the XmlSerializer be able to deserialize this, since it produced the xml string in the first place?

how to get the value of a class property using reflection?

i have a class like this..public class MyClass{List<ValueObjectClass> SampleList {get; set;}...}how can i get the value of MyClass.SampleList using reflection and convert it to List<T>?thanks..

How can I get a user list based on a specific profile property.

Hi,I am trying to query a DB and get a list of users based on a specific boolean property stored in the aspnet_profile for that user.I am aware that it wasn't possible a few years ago (http://forums.asp.net/p/988051/1277359.aspx), but was wondering whether that had changed in recent releases, or it was still not possible without trawling through the entire list of users and testing them one by one.  (My DB may become way to big for that.)Thanks in advance for any help.Regards,Ben

set the Report URL property to a specific report dynamically based on the selection in the list.

Hi I want to use  embedding the Report Viewer Web Part in a Web page, and I know we  should set the Report URL property to a specific report. but  is there a way by which we can set the url  dynamically based on the selection of the report  from  the list How can I customize this  feature Any Help on this is appreciated. Thanks

Class Property, using Set


My class uses a dataset and a property to "get" and "set" the rows in a SQL table called GROUPS into a class table called tblGroups.  In my constructor I select the contents of the GROUPS datatable and use the "Set" code in the property to populate tblGroups as follows"

Here is the property in the class:

    Private tblGroups As DataTable = New DataTable

    Public Property Groups() As DataTable
            Groups = tblGroups
        End Get
        Set(ByVal value As DataTable)
            tblGroups = value
        End Set
    End Property


Constructor Code:

Groups = ds.Tables("Groups")



When instantiating a new class object the set code above does a fine job of loading any existing records into my tblGroups table.  Now I wish to add additional records into that table.  What is the best way to accomplish this?

  • Do I need to create a seperate method to handle this, or should I change the existing "set" code somehow?
  • If the answer is to change the "set" code, can I add additional byVal variables?
  • If so, then how do I accomplish that without c

how to change button backcolor property on a form from a class file


Hello friends,

I am having a problem of updating the main form button backcolor property from another class. I have attahced the code. Please tell how can i rectify this problem.

PopUp is another class, in which i want that when ToolStripDropDown closes it change the form button BackColor from Orange to WhiteSmoke.


public partial class PopUp : ToolStripDropDown


        public PopUp()





        protected override void OnClosed(ToolStripDropDownClosedEventArgs e)


               Form1 f1 = new Form1();

              // f1._pushed = false;

       f1.Controls["button1"].BackColor = Color.WhiteSmoke;





It seems that this line works, i checked it using MessageBox it changes the backcolor property but it does not updated to the form displayed on the screen. 

Can anyone help me

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

2010 Collection class syntax/property problem

I converted a project from 2008 to 2010 to be able to use the TPL.

I've updated the compile target to .NET 4. Everything seems good, including the .NET 4 specific TPL stuff...except that:

Parallel.ForEach(MyClassCollection.Cast(Of MyClass), (Sub(ANYTHING As MYClass) ANYTHING.MySubRoutine()))

Gives the following as a syntax error:

Error 2 'Cast' is not a member of 'Microsoft.VisualBasic.Collection'. C:\Users\jeff\Documents\Visual Studio 2010\Projects\MyProject\MyProject\RunLoop.vb 229 34 MyProject

Any ideas?


How to get child property inside parent class, with lambda?


Hi all,

Could you answer me how to do next, please? How to do this with Lambda? Is it possible to delegate some object instance and use its properties and methods in case if this method doesn't know type of delegated object?

class class_a {
    public string getChildData<T> (T dynamicInstance) {
        return dynamicInstance.prop;

class class_b : a {
    public string prop = "prop_b";

class class_c : a {
    public string prop = "prop_c";

var inst_b = new b ();
var inst_c = new c ();

Purpose : to get child property inside parent class?

Thanks, Artem

Problem retrieving bit colum with sqldatareader for vb class property


 I have a vb class that reads a single row of data from an SQL view. I want to add a property to it that will expose the value of a new bit field. But whatever I do my class always returns the value "false".

What am I doing wrong?

       Public ReadOnly Property IsPublished() As Boolean
                Return valPublished
            End Get
        End Property

Here's the relevant line from my datareader:
        Me.valPublished = Convert.ToBoolean(theObjectReader("Authorised"))Authorised is my bit field. I have tried it with and without the "ConvertToBoolean" statement.
When I response write the value of the property for rows where this field is true, it always shows false.

Any ideas?

Unable to use Managed Property mapped to Choice Dropdown list column in MOSS 2007


I have a choice list column containing dropdown values. I crawled the content source and created Managed Property to map it.

Also Configured Advanced Search webpart to display the property. But when I pick the property and perform search with values then no results are returned.

Can any one can help me out.?

Thanks in Advance.!

Unable to bind a List of a [DataContract] class to a ListBox




I have a class who is used by Silverlight though RIA Services and who contains the [DataContract] and on its properties [DataMember].

That class is also used by my WPF Application and i have a List<myClass> which i want to bind it on ListBox.


The problem is when i bind the list, when i select an item in my listbox, the first item is always selected and the right-click doesn't work properly.

In fact, the behavior of UI is weird and badly refreshed.

But, before, the class didn't have DataContract/DataMember attributes and it worked fine.


Do you know, a workaround to continue to use that class and avoid to create an other class specially for databind ?





Xml Serialization: choose tag name for class instances in a generic ObservableCollection / List



I've creating a class called Graphics, deriving from a generic ObservableCollection where T is a custom class called Graphic :

public class Graphics : ObservableCollection<Graphic>
public Graphics()

Another class has a Graphics field. When I serialize to XML this class, this works fine :

  <Graphic id="1">
  <Graphic id="2">
  <Graphic id="3">

But I would like to have the following:

  <Gr id="1">
  <Gr id="2">
  <Gr id="3">

How can I process, I can't find a solution.

Please help.


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