Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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 September 27th, 2011, 06:22 AM
Registered User
 
Join Date: Sep 2011
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
Default Compiler Error Message: CS0542: 'Direction': member names cannot be the same as their

dear Imar

may be it is simple, plz help me.


SOURCE
---------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for Direction
/// </summary>
public class Direction
{

public enum Direction
{
Horizontal = 0

, Vertical = 1
}

public Direction()
{
//
// TODO: Add constructor logic here
//
}
}




COMPILATION
Source Error:

Line 10: {
Line 11:
Line 12: public enum Direction
Line 13: {
Line 14: Horizontal = 0


Source File: c:\BEGASPNET\site\App_Code\Direction.cs Line: 12
 
Old September 27th, 2011, 11:18 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You have an enum named the same as a class. Now, you have the enum nested inside the class which should technically work, however, it isn't good form to have things named the same. Many people add a suffixes to enums to make their types more descriptive and indicative of them being an enum. I often use "Type", such as "DirectionType". This should eliminate the error.
__________________
-Peter
compiledthoughts.com
twitter/peterlanoie
The Following User Says Thank You to planoie For This Useful Post:
anjumk (September 28th, 2011)
 
Old September 27th, 2011, 02:40 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

In addition to Peter's reply, the idea of Direction.cs is to contain just the Enum. There's not need for the wrapping class. The following in that file should be enough:

Code:
 
public enum Direction
{
  Horizontal = 0, 
  Vertical = 1
}
Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
anjumk (September 28th, 2011)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiler Error Message: BC30037: Character is not valid. danielv243 Visual Studio 2005 0 November 4th, 2009 11:52 PM
Compiler Error Message: BC30456: 'dgproducts_editc sunitha50 ASP.NET 2.0 Basics 0 February 27th, 2007 12:43 PM
Compiler Error Message: BC30456: crmpicco ASP.NET 2.0 Basics 3 November 30th, 2006 07:40 AM
Compiler Error Message: BC30456 yaip All Other Wrox Books 6 October 12th, 2006 02:56 PM
Compiler Error Message: CS0246: The type or namesp frmsasp All Other Wrox Books 0 September 17th, 2005 09:13 AM





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