Solved

asp.net for loop alphabets

Posted on 2010-09-17
2
449 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

728 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