Use break
.
Unrelated to your question, I see in your code the line:
Violated = !(name.firstname == null) ? false : true;
In this line, you take a boolean value (name.firstname == null)
. Then, you apply the !
operator to it. Then, if the value is true, you set Violated to false; otherwise to true. So basically, Violated is set to the same value as the original expression (name.firstname == null)
. Why not use that, as in:
Violated = (name.firstname == null);
Related Posts:
- How do you get the index of the current iteration of a foreach loop?
- How can I parse JSON with C#?
- What is IP address ‘::1’?
- What is the yield keyword used for in C#?
- Join/Where with LINQ and Lambda
- C# compiler error: “not all code paths return a value”
- C# equivalent of C++ map
- How to convert byte array to string [duplicate]
- C# Java HashMap equivalent
- The page was not displayed because the request entity is too large on IIS
- Configuration System Failed to Initialize
- Export Pervasive to MySQL (C#)
- Why use the params keyword?
- What does plus equals(+=) operator means here?
- Unity cannot convert from ‘string’ to ‘int’
- The request was aborted: Could not create SSL/TLS secure channel
- The request was aborted: Could not create SSL/TLS secure channel
- finding the maximum length of lists in c#
- The located assembly’s manifest definition does not match the assembly reference
- OnTriggerEnter not working at Unity3D
- The requested resource does not support HTTP method ‘GET’
- How can I find a specific element in a List
? - Rename a file in C#
- What does mscorlib stand for?
- XAML Binding Groups
- What is the best way to iterate over a dictionary?
- Does not contain a static ‘main’ method suitable for an entry point
- Checking if an object is null in C#
- How to use Global Variables in C#?
- What is and how to fix System.TypeInitializationException error?
- How to bind a model to a kendo Combobox in order to use the models validatation?
- HttpWebRequest-The remote server returned an error: (400) Bad Request
- MSHTML DLL on Windows 10
- Adding values to a C# array
- C#: how to get first char of a string?
- how to convert C# to C++
- Adding values to a C# array
- Reading settings from app.config or web.config in .NET
- How to initialize a list of strings (List
) with many string values - What does {0} mean when found in a string in C#?
- How to use html.ValidationMessageFor
- EF 5 Enable-Migrations : No context type was found in the assembly
- Visual studio 2019 freezes when debugging
- How to make an HTTP POST web request
- How to add comments into a Xaml file in WPF?
- Are 2 dimensional Lists possible in c#?
- Passing just a type as a parameter in C#
- How to easily initialize a list of Tuples?
- How do I target @Model within a src of an image tag?
- How to round up in c#
- How to stop C# console applications from closing automatically? [duplicate]
- Converting from IEnumerable to List
- Escape double quotes in a string
- How to do constructor chaining in C#
- Can I send SMS Messages from a C# Application?
- How do you sort a dictionary by value?
- EntityType has no key defined error
- regular expression “.*[^a-zA-Z0-9_].*”
- Sharing violation IOException while reading and writing to file C#
- How to delete object?
- WSACancelBlockingCall exception
- Carriage return and Line feed… Are both required in C#?
- Padding is invalid and cannot be removed?
- Inconsistent Accessibility: Parameter type is less accessible than method
- Why is it that “No HTTP resource was found that matches the request URI” here?
- How to get correct timestamp in C#
- Best way to reverse a string
- C# Foreach statement does not contain public definition for GetEnumerator
- Cannot implicitly convert type ‘int’ to ‘string’ C# class
- How can I know if a process is running?
- Fastest way to remove first char in a String
- How to convert datetime format to date format in crystal report using C#?
- Most efficient way to remove special characters from string
- When do we use ANTLR
- How to convert UTF-8 byte[] to string
- How would you count occurrences of a string (actually a char) within a string?
- Socket.Select returns error “An operation was attempted on something that is not a socket”
- Get dictionary key by value
- Rotate object in Unity 3D
- C# equivalent to Java’s charAt()?
- How to play a sound in C#, .NET
- Convert SQL to LINQ Query
- How to resolve file being used by another process?
- How to crop an image using C#?
- c# .net change label text
- Check if a string is a palindrome
- Authorization has been denied for this request – New Web API Project
- How do you wait for input on the same Console.WriteLine() line?
- Why doesn’t C# have header files? Will the namespace take care of everything?
- How to avoid a System.Runtime.InteropServices.COMException?
- Define: What is a HashSet?
- Convert string to decimal, keeping fractions
- “A namespace cannot directly contain members such as fields or methods”
- Format of the initialization string does not conform to specification starting at index 0
- How can I generate random alphanumeric strings?
- How do you do a deep copy of an object in .NET?
- Cannot declare instance members in a static class in C#
- Error: “an object reference is required for the non-static field, method or property…” [duplicate]
- How to convert HTML to PDF using iTextSharp
- Linq: GroupBy, Sum and Count