Solved

MyText Project

Posted on 2012-03-24
2
391 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
2 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Javascript to set controls visibility 5 34
imap mails 1 22
Sending receiving text messages in vb.net 15 35
asp.net mvc5 6 16
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

773 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