Click here to Skip to main content
15,889,854 members
Home / Discussions / C#
   

C#

 
Questioneasy question for profeesionall programmers... Pin
mr.mohsen25-Jul-08 21:32
mr.mohsen25-Jul-08 21:32 
AnswerRe: easy question for profeesionall programmers... Pin
Hesham Amin25-Jul-08 21:47
Hesham Amin25-Jul-08 21:47 
AnswerRe: easy question for profeesionall programmers... Pin
DaveyM6925-Jul-08 22:48
professionalDaveyM6925-Jul-08 22:48 
AnswerRe: easy question for profeesionall programmers... Pin
Paul Conrad26-Jul-08 11:03
professionalPaul Conrad26-Jul-08 11:03 
Questionlogical and operator Pin
Zeyad Jalil25-Jul-08 21:25
professionalZeyad Jalil25-Jul-08 21:25 
AnswerRe: logical and operator Pin
Hesham Amin25-Jul-08 21:38
Hesham Amin25-Jul-08 21:38 
AnswerRe: logical and operator Pin
mr.mohsen25-Jul-08 21:41
mr.mohsen25-Jul-08 21:41 
AnswerRe: logical and operator Pin
DaveyM6925-Jul-08 22:43
professionalDaveyM6925-Jul-08 22:43 
Create your own class or struct and use operator overloading. The code below should get you started. The logical && operator cannot be overloaded but it is evaluated using the binary operator & which can.
using System;

namespace MyApp
{
    public struct MyString : 
        IComparable, IComparable<MyString>,
        IEquatable<MyString>
    {
        // Member Variable
        private string m_Value;

        // Constructor
        public MyString(string value)
        {
            m_Value = value;
        }

        // Implicit Conversions
        public static implicit operator MyString(string value)
        {
            return new MyString(value);
        }
        public static implicit operator string(MyString value)
        {
            return value.m_Value;
        }

        // Operator Overloads
        public static MyString operator &(MyString myStringA, MyString myStringB)
        {
            MyString rtn = new MyString();
            // Do your stuff here
            return rtn;
        }

        // ToString Methods
        public override string ToString()
        {
            return m_Value;
        }

        // CompareTo Methods
        public int CompareTo(object value)
        {
            int rtn = -1;
            if (value is MyString)
            {
                MyString compareToValue = (MyString)value;
                rtn = CompareTo(compareToValue);
            }
            return rtn;
        }
        public int CompareTo(MyString value)
        {
            return m_Value.CompareTo(value.m_Value);
        }

        // Equals Methods
        public bool Equals(MyString obj)
        {
            return Equals(obj);
        }
    }
}


Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

AnswerRe: logical and operator Pin
Ed.Poore25-Jul-08 22:47
Ed.Poore25-Jul-08 22:47 
Questionconnecting local network server for updating in c sharp Pin
maheshChowta25-Jul-08 19:10
maheshChowta25-Jul-08 19:10 
AnswerRe: connecting local network server for updating in c sharp Pin
Ed.Poore25-Jul-08 22:30
Ed.Poore25-Jul-08 22:30 
QuestionButton removed but not disposed Pin
netJP12L25-Jul-08 18:33
netJP12L25-Jul-08 18:33 
AnswerRe: Button removed but not disposed Pin
Ed.Poore25-Jul-08 22:28
Ed.Poore25-Jul-08 22:28 
GeneralRe: Button removed but not disposed Pin
netJP12L26-Jul-08 5:05
netJP12L26-Jul-08 5:05 
GeneralRe: Button removed but not disposed Pin
Ed.Poore26-Jul-08 8:58
Ed.Poore26-Jul-08 8:58 
Questiondeterming the full name to My Music on the start menu Pin
Jason Coggins25-Jul-08 16:56
Jason Coggins25-Jul-08 16:56 
AnswerRe: determing the full name to My Music on the start menu Pin
mr.mohsen25-Jul-08 21:37
mr.mohsen25-Jul-08 21:37 
AnswerRe: determing the full name to My Music on the start menu Pin
Ed.Poore25-Jul-08 22:54
Ed.Poore25-Jul-08 22:54 
AnswerRe: determing the full name to My Music on the start menu Pin
DaveyM6925-Jul-08 23:01
professionalDaveyM6925-Jul-08 23:01 
AnswerRe: determing the full name to My Music on the start menu Pin
Luc Pattyn26-Jul-08 2:47
sitebuilderLuc Pattyn26-Jul-08 2:47 
QuestionOverriding ToString() with arguments Pin
JoeRip25-Jul-08 16:05
JoeRip25-Jul-08 16:05 
AnswerRe: Overriding ToString() with arguments Pin
PIEBALDconsult25-Jul-08 19:35
mvePIEBALDconsult25-Jul-08 19:35 
GeneralRe: Overriding ToString() with arguments Pin
JoeRip25-Jul-08 23:13
JoeRip25-Jul-08 23:13 
GeneralRe: Overriding ToString() with arguments Pin
JoeRip25-Jul-08 23:51
JoeRip25-Jul-08 23:51 
GeneralRe: Overriding ToString() with arguments Pin
PIEBALDconsult26-Jul-08 3:35
mvePIEBALDconsult26-Jul-08 3:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.