473,756 Members | 9,662 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# Properties & Method!

Hi all,

Can I have a class that contains a IsDirector Method & IsDirector property.
The method populates the property.

I have tried the code below..but get a 'definition for IsDirector' already
exists.

Cheers,
Adam

using System;
using System.Web;
public class Security
{
//private variable declarations
private Boolean _IsDirector;
private System.Web.Sess ionState.HttpSe ssionState Session;

public Security()
{
//initialise class properties
_IsDirector = IsDirector();
}

public Boolean IsDirector()
{
//determine if a user session is exists
if(null != System.Web.Http Context.Current .Session)
{
//retrieve session object from page
Session = System.Web.Http Context.Current .Session;

//determine if logged in user belongs to the directors user group
if ((int)Session(" GroupID") = 1)
{
//return boolean indicating user is a director
return true;
}
}

//return boolean indicate user is not a director
return false;
}

public Boolean IsDirector
{
get
{
return _IsDirector;
}
}

}
Nov 19 '05 #1
3 1150
You cannot have both a property and a method, you'll get naming conflicts.
Cheers,
//Rutger

http://www.RutgerSmit.com
Nov 19 '05 #2
Adam,

Consider putting the code from the IsDirector method inside the get{..}
clause of the IsDirector property. If you don't want to run this code on
every use of the IsDirector property, introduce another boolean variable
that will tell you if you have already run the code once.

Eliyahu

"Adam Knight" <de*@brightidea .com.au> wrote in message
news:Of******** ******@TK2MSFTN GP12.phx.gbl...
Hi all,

Can I have a class that contains a IsDirector Method & IsDirector property. The method populates the property.

I have tried the code below..but get a 'definition for IsDirector' already
exists.

Cheers,
Adam

using System;
using System.Web;
public class Security
{
//private variable declarations
private Boolean _IsDirector;
private System.Web.Sess ionState.HttpSe ssionState Session;

public Security()
{
//initialise class properties
_IsDirector = IsDirector();
}

public Boolean IsDirector()
{
//determine if a user session is exists
if(null != System.Web.Http Context.Current .Session)
{
//retrieve session object from page
Session = System.Web.Http Context.Current .Session;

//determine if logged in user belongs to the directors user group if ((int)Session(" GroupID") = 1)
{
//return boolean indicating user is a director
return true;
}
}

//return boolean indicate user is not a director
return false;
}

public Boolean IsDirector
{
get
{
return _IsDirector;
}
}

}

Nov 19 '05 #3
Try changing the name such as

isDirector for Property (1st letter lower case)
IsDirector for Method (1st letter upper case)

or

IsDirectorP for property
IsDirdctor for method

and so on.

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
11459
by: Paul | last post by:
Hello, I've been reading up on security in Java Applets and whilst I understand the concept, I can't successfully get my applet to read a file on my local machine. I discovered from http://java.sun.com/sfaq/#read: ----- Sun's appletviewer allows applets to read files that are named on the access control list for reading. The access control list for reading is null by default, in the JDK. You can allow applets to read directories or files...
0
2422
by: Thomas Scheffler | last post by:
Hi, I runned in trouble using XALAN for XSL-Transformation. The following snipplet show what I mean: <a href="http://blah.com/?test=test&amp;test2=test2">Test1&amp;</a> <a href="http://blah.com/?test=test&amp;amp;test2=test2">Test2&amp;amp;</a> This results in the following HTML Code:
12
9472
by: Sammy | last post by:
Hi, my mind is going crazy. I have tried everything I can think of to no avail. I have tried Disable Output Escaping. I tried to think of a way of enclosing the attribute data in a CDATA element. That did not parse. Here is my question: How can I get attribute values to not get converted from &apos; to '
4
3228
by: johkar | last post by:
When the output method is set to xml, even though I have CDATA around my JavaScript, the operaters of && and < are converted to XML character entities which causes errors in my JavaScript. I know that I could externalize my JavaScript, but that will not be practical throughout this application. Is there any way to get around this issue? Xalan processor. Stripped down stylesheet below along with XHTML output. <?xml version='1.0'?>...
1
1689
by: Christophe Peillet | last post by:
I have a CompositeControl with two types of properties: 1.) Mapped Properties that map directly to a child control's properties (ex.: this.TextboxText = m_txt.Text). These properties are handled by their underlying classes (such as the TextBox control), and are not persisted by me. 2.) Unique Properties that don't map directly and are persisted in ViewState (ex.: this.LabelPosition, which specifies where on the form the label should be...
8
2818
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);" TextBox2.Attributes.Add("onKeyPress", jscode) You will notice that jscode contains the JavaScript Logical And operator (&&). However, ASP.NET renders this as &amp;&amp; in the code that is
17
1529
by: Bruce One | last post by:
Lets consider a class called Currency. This class must be the responsible for taking care of all calculations over currency exchanges, in such a way that I pass values in Euros and it returns the converted value in Dollar for example... Well, I might do this in 2 ways, as below: 1) I create a method like this: double ConvertValue (double OriginalValue) { // here I compute the value
3
3235
by: Nathan Sokalski | last post by:
I am adding an onmouseover attribute using the Attributes.Add() method, and the String I am using for the value contains the & character. However, when rendered the & is converted to the HTML representation of &amp; which causes my JavaScript not to work. What can I do to prevent the Add() method from modifying my value? Thanks. -- Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
0
9482
marktang
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...
1
9878
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,...
0
9728
tracyyun
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...
0
8733
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7282
isladogs
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...
0
6551
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();...
0
5322
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3827
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
3
2694
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.