Skip to main content

ArrayList IsFixedSize property in c#

ArrayList IsFixedSize Property
.Net framework ArrayList IsFixedSize property allow us to get a value indicating whether the ArrayList has a fixed size. the arraylist IsFixedSize property exists in System.Collections namespace. this property has no optional or required parameter.

arraylist IsFixedSize property return value type is System.Boolean. this property boolean value return 'true', if the arraylist has a fixed size; otherwise it returns 'false'. this property default value is 'false'. the arraylist IsFixedSize property implements as IList.IsFixedSize.

a fixed size arraylist does not allow the addition or removal of elements after the arraylist (collection) is created. but fixed size arraylist allow the modification (update) of existing elements.

the following c# example code demonstrate us how can we determine whether an arraylist has a fixed size programmatically at run time in an application.

<%@ Page Language="C#" AutoEventWireup="true" %>

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
        ArrayList colors = new ArrayList() { "Blue", "SkyBlue", "LightBlue" };

        Label1.Text = "<font color=DodgerBlue>'colors' ArrayList Elements... ";
        foreach (string color in colors)
            Label1.Text += "<br />" + color;
        Label1.Text += "</font>";

        ArrayList fixedSizeColors = ArrayList.FixedSize(colors);

        Label1.Text += "<br /><br />Is 'colors' ArrayList FixedSize? " + colors.IsFixedSize.ToString();
        Label1.Text += "<br />Is 'fixedSizeColors' ArrayList FixedSize? " + fixedSizeColors.IsFixedSize.ToString();

        //Uncomment this line to get error message, because fixed size ArrayList does not support add/remove
        Label1.Text += "<br /><br /><font color=DodgerBlue>After Adding 'Green', Now 'colors' ArrayList Elements... ";
        foreach (string color in colors)
            Label1.Text += "<br />" + color;
        Label1.Text += "</font>";

        fixedSizeColors[1] = "Crimson";
        Label1.Text += "<br /><br />After modify 'index 1', Now 'fixedSizeColors' ArrayList Elements... <font color=DodgerBlue>";
        foreach (string color in fixedSizeColors)
            Label1.Text += "<br />" + color;
        Label1.Text += "</font>";

<html xmlns="">
<head id="Head1" runat="server">
    <title>ArrayList IsFixedSize Property - How to get whether the ArrayList has a fixed size</title>
    <form id="form1" runat="server">
        <h2 style="color:MidnightBlue; font-style:italic;">
            System.Collections.ArrayList IsFixedSize Property
            <br /> How to get a value indicating whether
            <br /> the ArrayList has a fixed size
        <hr width="325" align="left" color="Navy" />
             Font-Names="Courier New"
        <br />
            Text="Test ArrayList IsFixedSize Property"
More examples

Popular posts from this blog

How to use Table in

Table Web Server Control ASP.NET Table web server control display a table on a web page. It is a .NET web server control so we can program it in server code such as add, remove table row, cell programmatically. TableRow and TableCell web server controls allow us to display content for the Table. Table server control display tabular data and we can format Table server control using it's built in methods and properties. The big difference between HTML table and Table server control is that we can manipulate Table server control using an object model. Generally we should use Table server control when we intend to add remove rows and cells (columns) programmatically at run time.

Table server control acts as a parent (container) for TableRows controls. Table control's Rows property is a collection of TableRow objects. each TableRow control has a collection named Cells. Cells collection contains TableCell objects.

Actually table server control display the TableCell con…

How to use RadioButton control in c#

RadioButton web server control RadioButton control lets you make a group of radio buttons with other RadioButton. If you set it's GroupName property same for multiple radio buttons then all radio buttons with same name act as a single group. Within a group you can only select one RadioButton at a time. RadioButton group work as like RadioButtonList. With RadioButton control you can more customize it than RadioButtonList items.

Back color, border color, border style, font names, font bold, font italic, fore color (text color) and many more property help you to design RadioButton. It also support CSS class, theme and skin. Even validation are works with RadioButton control. RadioButton have AutoPostBack property and CheckChanged event. By using those feature you can determine immediately which RadioButton is selected from a group.

This example uses a RadioButton group with two RadioButton. Here we assign AutoPostBack property value to true and setup a CheckChanged event. When …

How to use RadioButtonList control in c#

RadioButtonList web server control ASP.NET RadioButtonList control enable user to select an item from list. RadioButtonList support data bind programmatically from database. We can also populate it manually by input list item inside RadioButtonList tag. RadioButtonList is a single selection radio button group. RadioButtonList have an items collection. We can determine which item is selected by test it's SelectedItem property.

We can change RadioButtonList design by setting up it's various property as like BackColor, BorderColor, BorderStyle, BorderWidth, CellPadding, CellSpacing, CssClass, Font-Bold, Font-Italic, Font-Names, Font-Overline, Font-Size etc. there are more three properties RepeatColumns, RepeatDirection and RepeatLayout which help you to place list item vertically or horizontally.

RadioButtonList have standard AutoPostBack property. As like other list control RadioButtonList have an excellent event SelectedIndexChanged. So that when someone select an item it…