is there another way to write this code other than using bool for validation

bool isValid = true;

Yes, any integer-like variable type:

short isValid = 1;

0 is the same as false, and any other value is equal to true. One such instance in which this would be a useful tactic is error handling, where false would mean no error occurred, and any true statement means an error occurred, using the specific value of the integer to find which error precisely occurred.

More often than not, however, if you need to make a check between simple true and false, bool is the way to go, since it is one of the smallest variables(usually half the size of short, which is usually half the size of int). Only use an alternative if you have a implementation-specific reason to.

Why are you asking?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.