Solved

asp.net for loop alphabets

Posted on 2010-09-17
2
447 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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