Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Check to see if the name, is in proper case, which means the first letter must be uppercase and the rest of the letters must be lower case. In
the cases where name is null, empty, or is less than 2 characters long, return false. Do not take into account leading or trailing spaces.
public static bool NameIsInProperCase(string name)
{

}

What I have tried:

i can not access the attempts i made in my pc at work, I am currently downloading c# IDE to try again over the weekend. I am new to Linq.
Posted
Updated 17-Jul-17 6:38am

Don't use Linq - it's good when you want to do the same thing to all elements of a sequence, but useless when you want the first treated differently.
Instead, use a regex:
^[A-Z][a-z]+$
Should do it.
 
Share this answer
 
Comments
Member 13311188 15-Jul-17 10:03am    
regex will be my next topic to study, I am still trying to get a grasp over linq, the question is required to be answered in linq
OriginalGriff 15-Jul-17 10:13am    
So.
This isn't "work" - it's "homework".
Don't lie to people, it doesn't make us like you.

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
Member 13311188 15-Jul-17 10:20am    
this is work, I am studying for work, there is no tutor or homework. i finished my third year of university on the 7th june. this is a trainee position, I am trying my best to learn all I can about c#, in university I have never posted a single question, I discussed the questions I had with my tutors and my colleagues, did you really just take the single word "study" to relate it to homework, people study for all different reasons, one of them is that i did not have c# in my curriculum rather java. I am already under stress to elaborate on a single word in my comment. among all 5 categories, I have answered all questions with no problems even better than my colleagues that started weeks before me. but thank you for your feedback on how to discuss matters with my tutor, I have done that for years.
OriginalGriff 15-Jul-17 10:31am    
"studying" makes it homework!
If we do it for you, you learn nothing from it - you learn by doing, not copying. And we cannot support you through your entire career as a C# developer - that would hardly be fair given that you would be getting the wages and we would be doing the work.
Unless you lied to get the job and said you knew C# when you didn't, your employer should be aware that proficiency in any .NET language from scratch is at best around six months - the framework is HUGE and Java experience doesn't help at all.
Member 13311188 15-Jul-17 10:23am    
I have 2 weeks to write codes for over 300 methods, I am stuck with 22 of them. your help would be appreciated. I am already watching tutorials on linq, but it looks too massive to get a grip over in 2 or 3 days. there will be further 3 months of intensive training after once I get over this part.
Quote:
Please see the problem I have.

The problem you have is Homework !

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.

As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.

The idea of "development" is as the word suggests: "The systematic use of scientific and technical knowledge to meet specific objectives or requirements." BusinessDictionary.com[^]
That's not the same thing as "have a quick google and give up if I can't find exactly the right code".
 
Share this answer
 
Comments
Member 13311188 15-Jul-17 11:02am    
I am not begging anyone, there are no books to read. I am doing my research online, and on youtube and anywhere where c# tutorials are available. I have not told my employer I know c# and to be honest, after reading the comments there is no way I can answer linq and (clearly regex that I didn't know it even existed) in two weeks.
but regardless of how impossible it is, I am much better than 2 days ago when I knew nothing about c#. I am watching linq tutorials and I wrote codes for over 30 methods at the beginning of the training. by the end of the weekend, I will know more. I can not get the IDE to open the files, so I can not show you what I have done so far. I have done bloody good for someone that did not know anything about linq 2 days ago.
Michael_Davies 15-Jul-17 11:05am    
The files are text files you do not need the IDE to open them, any text editor will do, even Notepad.
Member 13311188 15-Jul-17 11:26am    
You will be given a long text composed of words which are seperated by space. Your task is put a '*' between each letter of each word, but you may not put a '*' between words,or at the beginning of end of the words. You don't need to worry about punctuation marks ('.', ',', ';') but you must preserve multiple spaces. Example:text = "This is an example of what I have in mind"Result:". T*h*i*s i*s a*n e*x*a*m*p*l*e o*f w*h*a*t I h*a*v*e i*n m*i*n*d".


public static string PutStarBetweenEachLetter(string text) 
{ 
    return text.Split(' ').Select(i => i.ToCharArray().ToString("*")).ToString(" "); 
} 
......................here is an example of the work I have done. I can only find it as it appears as solved and the solution is printed next to the question. the rest of the problems appear as a link, every time I open the problems I couldn't solve from my home pc using c# IDE i get the following message // there is no editor available for c:\.......................... (file path) Make sure the application for the file type(.cs) is installed. I am tired. where do I find the editor. I am new.
Patrice T 15-Jul-17 13:06pm    
Why didn't you showed your work in first place ?
On this site, we have students posting their homework verbatim and expect us to do the work. But we don't, thus the answers you get.

Open a new question with this problem, your work, and an explanation of what go wrong, and you will get useful solutions.
Patrice T 15-Jul-17 13:09pm    
For this problem, the solution is RegEx
public static bool NameIsInProperCase(string name) 
{ 
    name = name.Or("").Trim(); 
     
    if (name.Length < 2) return false; 
     
    return (name[0].IsUpper() && name.ExceptFirst().All(c => c.IsLower())); 
}


Hey guys, thanks everyone. I am almost finished for the day, but thanks everyone for your help. the solution with Regex was not accepted but between my colleagues and I we managed to figure it out.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900