Solved

asp.net for loop alphabets

Posted on 2010-09-17
2
438 Views
Last Modified: 2012-05-10
I have nested for loop in asp.net C# page

I want each item in the first for loop to be A ,B,C,D,E...
and the items in inside loop to be 1.1,1.2,1.3... in A
2.1,2.2,2.3.. in B

A.test
1.1
1.2
1.3
B mytest
2.1
2.2
2.3
C gtest
3.1.
3.2
3.3
3.4
.
.
.
.
and so on
Any help appreciated
0
Comment
Question by:Angela4eva
2 Comments
 
LVL 16

Accepted Solution

by:
kris_per earned 500 total points
ID: 33705019

Something like this? Hope it gives you the idea to suit yours...



            for (char alpha = 'A'; alpha <= 'Z'; alpha++)

            {

                Console.WriteLine(alpha);



                int sectionNum = alpha - 'A' + 1;



                // the criteria for the second part of num is not mentioned in your question

                // it is taken as 4 for all sections

                for (int subSectionNum = 1; subSectionNum <= 4; subSectionNum++)

                {

                    Console.WriteLine(sectionNum + "." + subSectionNum);

                }

            }



            // Output of this will be:

            A

            1.1

            1.2

            1.3

            1.4

            B

            2.1

            2.2

            2.3

            2.4

            ...

            till Z

Open in new window

0
 

Author Closing Comment

by:Angela4eva
ID: 33718452
great. thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now