Jump to content

i need help.....what the mean of this statement?

- - - - -

  • Please log in to reply
1 reply to this topic

#1
amr magdey

amr magdey

    Newbie

  • Members
  • Pip
  • 1 posts
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WindowsFormsApplication1
{
enum TokenType { ID, NUM, WS, ERROR, EOF}

class Token
{
private string _lexeme;
private TokenType _type;

public Token(TokenType type, string lexeme)
{
_type = type;
_lexeme = lexeme;
}

public string Lexeme { get { return _lexeme; } } // that is the statement i need to have its meaning

public TokenType Type { get { return _type; } }
}

any body can help me?;)
}

#2
fayyazlodhi

fayyazlodhi

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 403 posts
This is called accessor method and is used to get value of that field/property.

When you write <class object>.Lexeme it will read the private field lexeme's value. The advantage is you can allow easy ways for people read class's private field's value.

If you do not add a corresponding set, then one can read but cannot change the value. Have a look at following msdn article

get (C#)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users