Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

MyText Project

Posted on 2012-03-24
2
Medium Priority
?
400 Views
Last Modified: 2012-03-24
I am getting this error. Can you help me with this issue?  Please be very specific with the discussion.  I am a student and in of need of information.  I have been given permission to get help with my projects from tutors.  

I must create a script that takes text that a user enters into a form field and converts it to title case capitalization.  Use a split()  method to split words in the string into an indexed array.  Then create a for loop that uses another split() method that splits each word in the elements of the indexed array into another another indexed array of characters.  Within the for loop, us he ToUpper() method to convert the first element in the second array (which represents the first characters in the word to uppercase) to uppercase, and then use the Join() method to rebuild the array of words in the text string.  Execute a final Join() method to convert the array of words back into a single text strin.  Save the project as TitleCase.
TitleCase.zip
error.docx
0
Comment
Question by:assaultkitty
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 2000 total points
ID: 37761063
A NullReferenceException means that an object you are trying to use is not initialized.

If you put the cursor over myText when you get the error, you will probably see that its value is null. This means that your request did not return any value. Your "stringOfWords" element is probably empty.

Whenever you are retrieving information and expect that it could be empty, you need to check for the condition before using the returned value:
string myText = Request.Form["stringOfWords"];
string[] myTextArray;

if ( !( myText == null ) )
     myTextArray = myText.Split ( ' ' );
else
     // Output a message or deal with the situation any way you see fit

Open in new window

Further on, no need to split the string into an array of characters. A .NET string is already an array or characters. You can access them individually as myTextArray[0][0], myTextArray[0][1]...myTextArray[1][0], myTextArray[1][1]...
I leave the rest to you... you need to work a little in order to learn :-)
0
 

Author Closing Comment

by:assaultkitty
ID: 37761335
string myText = Request.Form["stringOfWords"];
string[] myTextArray = myText.Split(' ');

This is the way that I did it.  Thanks for the hint.  I have problem with another issue. Thanks again.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question