Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any common uses of C# do-while loop in web development? [closed]

I've been coding for a long, long time, self-taught. Now that I'm working toward my computer science degree, my programming class is talking about post-test loops, the do-while loop.

Now I understand that it runs once, then checks the condition... since I'm a web programmer, I was wondering: what are some common web development (ASP.NET MVC/Razor preferably) scenarios where a do-while loop fits perfectly?

I'm not quite getting the concept straight in my mind...

like image 680
Chaddeus Avatar asked Apr 29 '11 05:04

Chaddeus


People also ask

What is C commonly used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

Is C still widely used?

The C programming language will turn fifty years old in 2022. Yet despite its long history, C remains one of the top "most-used" programming languages in many "popular programming languages" surveys. For example, check out the TIOBE Index, which tracks the popularity of different programming languages.

Is C still used in 2022?

C is one of the earliest and most widely used programming languages. C is the fourth most popular programming language in the world as of January 2022. Modern languages such as Go, Swift, Scala, and Python are not as popular as C. Where is C used today?


2 Answers

I have been involved in many web projects and I can't remember for any specific use for this type of a loop. On web, you usually work just with collection of items and do some logic with each one of them. So I would say that most web developers just use foreach and for.

Do - While fits more into algorithms and calculations, and you don't do many of these in classic web development imo.

like image 155
Damb Avatar answered Oct 11 '22 06:10

Damb


I don't know about MVC specifically, but a couple of years ago I had to create a administration page to enter data, on the client side you could add new fields to add staff member profiles. (name, title, education)

The controls were created client-side with JavaScript and numbered in sequence like:

txtStaffName0

txtStaffName1

txtStaffName2

Then used a do/while with the condition checking for the next incremented number for a control. Something along the lines of:

int count = 0;
do
{
   //find control with count and do stuff...
   count++;
} while (DoesControlExist(count));

Apart from that I don't think I've ever seen do/while used in web related stuff...

like image 30
Phill Avatar answered Oct 11 '22 08:10

Phill