i got the following error when compiling the codes..
the name 'word' does not exist in the class or namespace 'SimpleMath.Pig '
Can anyone troubleshoot on this . Thank you
//////////////////////
using System;
namespace SimpleMath
{
/// <summary>
/// Pig Latin interpreter
/// Demonstrate loops, string methods
/// Andy Harris, 11/16/01
/// </summary>
class Pig
{
static void Main(string[] args)
{
string pigWord = "";
string sentence = "";
string firstLetter;
string restOfWord;
string vowels = "AEIOUaeiou ";
int letterPos;
while (sentence.ToLow er() != "quit"){
Console.WriteLi ne("Please enter a sentence (or type "quit"to exit)");
sentence = Console.ReadLin e();
foreach (string word in sentence.Split( ))
firstLetter = word.Substring( 0,1);
restOfWord = word.Substring( 1, word.Length -1);
letterPos = vowels.IndexOf( firstLetter);
if (letterPos == -1)
{
//it's a consonant
pigWord = restOfWord + firstLetter + "ay";
} else {
//it's a vowel
pigWord = word + "way";
} // end if
Console.Write(" {0} ", pigWord);
//debugging code
//Console.Write(" {0}", word);
//Console.Write(" {0}", firstLetter);
//Console.Write(" {0}", restOfWord);
//Console.Write(" {0}", letterPos);
//Console.WriteLi ne("{0}", pigWord);
}
}
}
} 1 1390
missing "{", the scope of word is just the statement
following the foreach.
foreach (string word in sentence.Split( ))
{ -----Original Message----- i got the following error when compiling the codes..
the name 'word' does not exist in the class or
namespace 'SimpleMath.Pig ' Can anyone troubleshoot on this . Thank you
////////////////////// using System;
namespace SimpleMath
{
/// <summary>
/// Pig Latin interpreter
/// Demonstrate loops, string methods
/// Andy Harris, 11/16/01
/// </summary>
class Pig
{
static void Main(string[] args)
{
string pigWord = "";
string sentence = "";
string firstLetter;
string restOfWord;
string vowels = "AEIOUaeiou ";
int letterPos;
while (sentence.ToLow er() != "quit"){
Console.WriteL ine("Please enter a sentence (or
type "quit"to exit)"); sentence = Console.ReadLin e();
foreach (string word in sentence.Split( ))
firstLetter = word.Substring( 0,1);
restOfWord = word.Substring( 1, word.Length -1);
letterPos = vowels.IndexOf( firstLetter);
if (letterPos == -1)
{
//it's a consonant
pigWord = restOfWord + firstLetter + "ay";
} else {
//it's a vowel
pigWord = word + "way";
} // end if
Console.Write( "{0} ", pigWord);
//debugging code
//Console.Write(" {0}", word);
//Console.Write(" {0}", firstLetter);
//Console.Write(" {0}", restOfWord);
//Console.Write(" {0}", letterPos);
//Console.WriteLi ne("{0}", pigWord);
}
}
}
} . This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: The Roys |
last post by:
Hi
Im doing something wrong in quitting the Word.Application in my VB program.
I have
General Declarations
Dim AppWord As Word.Application
Form_Load()
Set AppWord = CreateObject("Word.Application")
|
by: Jessard |
last post by:
Hi All,
I am writing a .NET app that accesses an access View. The view has a table
column called 'Position'. When i try and right an UpdateCommand string for
this using this column I am greeted with a 'Syntax error in Update
statement.' when attempting the update. I take that field out and the update
works. I am assuming Position is a reserved word. I have even tried
changing the name of the column in the View to something other...
|
by: gdogg1587 |
last post by:
Greetings.
I'm working on a program that will "descramble" words. Think of a word
scramble game where there is a list of characters, and several blank
spaces to denote the word(s) that you are to come up with from the list.
i.e.(* denotes a space): _ _ _ _ _ * _ _ _ _ _ _
characters: .hwodlelrlo
answer: hello world.
|
by: MaxiWheat |
last post by:
Hi,
I am using a software that uses MS Word to create PDF files. When I try
to run the sample code (ASP 3.0), I get an error on this statement :
Set oWord = Server.CreateObject("Word.Application")
That error says :
The call to Server.CreateObject failed while checking permissions.
Access is denied to this object.
|
by: Claus - Arcolutions |
last post by:
I got a word document as a stream, and I want to get the text from the word
document. But I cant seem to find anything to use for that purpose.
The "Microsoft office ?.object" com reference, only include functionality to
read from a file (as far as I know).
I looked a little on the structure of the document, but it doesnt seem to
have any common structures, especially not if you compare from different
office versions.
| |
by: kurtj |
last post by:
Hello Gurus:
I have a validation script (below) that is somehow messed up. If the
Name field is blank, I get the alert message, then the browser window
goes to a blank document with the word "false" on it. What the ?!?!?!
To test, I commented out the 'return false;' code in the second IF
block, so now if there is a value in Name then I get the alert message
for Email and the page stays put.
|
by: adam.timberlake |
last post by:
Me again! I am trying to create a currency converter function for my
eCommerce that still pet treats. I am a little short on money recently
and so cannot afford a programmer. Can somebody tell me why my script
tells me that I have a syntax error on the "CONST" line. I am trying
to follow the article below.
Article: http://www.talkphp.com/showthread.php?t=1503
The error I get is:
|
by: Vinodsrvk |
last post by:
I tried to execute the bellow query for the word "about" in the NARRATIVE field.
This narrative field is of CLOB type with NOTNULL
SELECT SEARCHID, NARRATIVE
FROM S.TBLSEARCH
WHERE CONTAINS(NARRATIVE, 'about') >0
/
|
by: arnuld |
last post by:
C takes input character by character. I did not find any Standard Library
function that can take a word as input. So I want to write one of my own
to be used with "Self Referential Structures" of section 6.5 of K&R2. K&R2
has their own version of <getwordwhich, I think, is quite different
from what I need:
<getwordwill have following properties:
1.) If the word contains any number like "beauty1" or "win2e" it will
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |