Solved

asp.net for loop alphabets

Posted on 2010-09-17
2
437 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
Comment Utility

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
Comment Utility
great. thanks
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 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

11 Experts available now in Live!

Get 1:1 Help Now