Wrox Programmer Forums
|
BOOK: Professional C# 2008 ISBN: 978-0-470-19137-8
This is the forum to discuss the Wrox book Professional C# 2008 by Christian Nagel, Bill Evjen, Jay Glynn, Morgan Skinner, Karli Watson; ISBN: 9780470191378
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional C# 2008 ISBN: 978-0-470-19137-8 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 7th, 2010, 01:31 AM
Authorized User
 
Join Date: Aug 2010
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Cade_Feng
Default There is something wrong in my code?

Hi, Eeveryone . I don't know what's wrong in my code. But i copy it from the professional C# 2008, page 33. attach my code.
Help me!!!
Code:
using System;

namespace Wrox.ProCSharp.Basics
{
	class ScopeTest
	{
		static int j = 20;
		Console.WriteLine(j);
		
		public static void Main()
		{
			int j = 30;
			Console.WriteLine(j);
			Console.WriteLine(ScopeTest.j);
			return;
		}
	}
}
__________________
Wana be a .net developer.
Sincere yours
Cade_Feng
 
Old August 7th, 2010, 05:18 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Delete the first occurance of:

Console.WriteLine(j);

Its an error.
 
Old August 7th, 2010, 11:44 AM
Authorized User
 
Join Date: Aug 2010
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Cade_Feng
Thumbs up

yeah. It did worked as I followed ur advices. But I copy this code form the book , Is the book print wrong? Anyway, I know how to fix it. Thanks for helping me.
__________________
Wana be a .net developer.
Sincere yours
Cade_Feng
 
Old March 4th, 2011, 02:17 AM
Authorized User
 
Join Date: Mar 2011
Posts: 17
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Console.WriteLine() can be contained only inside a method. Thats the reason why the error has occurred .





Similar Threads
Thread Thread Starter Forum Replies Last Post
what is wrong in this code cancertropica ADO.NET 4 December 21st, 2008 04:08 AM
what's wrong with this code? hertendreef Visual Basic 2005 Basics 0 March 2nd, 2007 10:29 AM
What's wrong with this code? AlDugan XSLT 3 May 19th, 2006 12:06 PM
What is wrong with code? rtr1900 Classic ASP Databases 1 April 3rd, 2006 03:20 AM
What Wrong Of My Code ck C++ Programming 0 January 27th, 2005 08:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.