473,387 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Break out of a loop in the main function through another function

Hope the title of the question explains what I need help on.

So here's the code that I think you'll need to understand what I'm talking about:

Expand|Select|Wrap|Line Numbers
  1. static void quit(string a, int b, ref List<string> c)
  2.     {
  3.         if (a == "-q")
  4.             c.RemoveRange(b + 1, c.Capacity - b);
  5.     }
  6.  
  7. static void Main(string[] args)
  8.     {
  9.             listNums = 0
  10.             List<string> output = new List<string>();
  11.             loop1 = true;
  12.  
  13.             while (loop1)
  14.             {
  15.                 Console.WriteLine("\nEpisode {0}: \nEnter Authentication Code:", epiStart);
  16.             authCode = Console.ReadLine();
  17.             quit(authCode, listNums, ref output);
  18.  
  19.             // if (authCode == "-q")
  20.         //    break; output.RemoveRange(listNums + 1, output.Capacity - listNums);
  21.         }
  22.          }
  23.  
So the question I'd be asking is this: How do I get the function "quit" to break the loop1 loop?

The code that I commented out works, but I want to make it into a function to use it again for code later on in the program.
May 25 '16 #1
0 1801

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Foxy Kav | last post by:
Hi everyone, im a first year UNI student doing a programming subject and im stuck on how to get rid of my global variables, char stringarray and char emptystring. I was wondering if anyone could...
4
by: wongjoekmeu | last post by:
Hello All, >From a book where I have learned C++ it says that each application must have at least one function which is the main() function. Now I have the source code of a C++ program from...
3
by: Richard A. DeVenezia | last post by:
Can a function write another function that has a specific number of nested loops and then run it? i.e. function maker (N) { // does stuff that creates function doer() // invoke doer doer() }
39
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. ...
89
by: Sweety | last post by:
hi, Is main function address is 657. its show in all compiler. try it & say why? bye,
1
by: shiniskumar | last post by:
i go tto perform some validation while ck=liking a button without refreshing the value.. i used ajax.My code is as follows...on button click i call the function validateGridAdd(); Inside tat...
2
by: Emil | last post by:
Is it posiible to create callback for a function, that is automatically called before that function returns? I need it for tracing/profiling purposes. eg.: var execTime = null; var startTime...
28
by: ravi | last post by:
Hello everybody, I am writing a small application which does some work before the user main function starts execution. I am trying to #define the main function. But the problem is that,
11
by: aarklon | last post by:
Hi all, I have heard many discussions among my colleagues that main is a user defined function or not. arguments in favour:- 1) if it is built in function it must be defined in some header...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.