TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Elizabeth Foster
NA
1
1.6k
The name '____' does not exist in current context.
Nov 5 2015 1:16 AM
There areas that this error is occurring is highlighted in yellow (there are only three).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace TaskoneBinaryConverstion
{
class Program
{
static string userNumber = "";
static int answer = 0;
static Boolean userInputOk = false;
static void Main()
{
do
{
Console.WriteLine("This program will convert binary to decimal");
//Give user instructions
Console.WriteLine("Please enter a binary number");
//read in the user binary number assign it to a variable
userNumber = Console.ReadLine();
if (userNumber != "")
{
userInputOk = true;
foreach (char currentChar in userNumber)
{
//checks individual digit to ensure it is either a 1 or 0
if (currentChar != '1' && currentChar != '0')
{
userInputOk = false;
Console.Clear();
Console.WriteLine("An error has occurred, please only use 1 or 0");
}
{
}
}
}
else
//if the user did not input either a one or zero the program will not preform the function and
//will re-iterate the question
userInputOk = false;
{
}
}
while (userInputOk == false);
// end loop when all digits have been delt with
//display convereted number
currentMultiplicationFactor();
Console.WriteLine("Answer= " + answer);
//prevent console from closing
Console.ReadKey();
//prevents program from crashing
//loop through the given number (string)
//starting from the last number down to the first number
}
//read from file method... this is the method which gets called if a valid file is found at the beginning.
private static void readFromFile()
{
//readFromFile binary lines from set file
String[] tempCodes = File.ReadAllLines(
armCodeFile
);
//execute the following code for each line of the file
foreach (string currentcode in tempCodes)
{
//set the code to the usernumber variable
UserNumber
= currentcode;
Calculatedecimal
();
//display the answer
Console.WriteLine(currentcode + " To decimal = " + answer);
}
}
private static void currentMultiplicationFactor()
{
answer = 0;
int currentMultiplicationFactor = 1;
for (int index = userNumber.Length - 1; index > -1; index--)
{
if (userNumber[index] == '1')
{
answer += currentMultiplicationFactor;
}
currentMultiplicationFactor *= 2;
}
}
}
}
Reply
Answers (
1
)
insert data in databse
how can use WEBMAIL