Wednesday, January 13, 2010

Images test for Wibiya Share app


Heidi Samuel[2] (born June 1, 1973)[3], better known by her birth name Heidi Klum, is a German American[4] model, actress, television host, business woman, fashion designer, television producer, artist, and occasional singer. She is married to singer Seal.

Contents

[hide]

[edit] Early life and discovery

Heidi was raised by her parents: Günther, a cosmetics-company executive; and Erna, a hairdresser; in Bergisch Gladbach, West Germany, a small city outside Cologne. A friend persuaded her to enroll in a national modeling contest called "Model 92".[5] Out of 25,000 contestants, Klum was voted the winner on April 29, 1992 and offered a modeling contract worth US$300,000 by Thomas Zeumer, CEO of Metropolitan Models New York.[6] As the winner, she appeared on the Gottschalk Late Night Show, a top German television show with host Thomas Gottschalk. She accepted the contract a few months later after graduating from school and decided not to try for an apprentice position at a fashion design school.[7]

[edit] Acting and modeling

Klum has been on the cover of fashion magazines, including Vogue, ELLE and Marie Claire. She became known after appearing on the cover of the Sports Illustrated Swimsuit Issue and for her work with Victoria's Secret as an "Angel."[8] Klum hosted the Victoria's Secret Fashion Show in 2009.

In addition to working with world class photographers on her Sports Illustrated shoots, she was the object and subject of Joanne Gair body painting works in several editions from 1999 to 2006. She wrote the foreword to Gair's book of body paint work. She was a spokesmodel for McDonald's, Braun, H & M, and Liz Claiborne, among others. She is currently a celebrity spokesmodel for Jordache[9] and Volkswagen. In addition to modeling, she has appeared in several TV shows, including Spin City, Sex and the City, Yes, Dear, and How I Met Your Mother. She had a role as an ill-tempered hair model in the movie Blow Dry, played a giantess in the movie Ella Enchanted and was cast as Ursula Andress in The Life and Death of Peter Sellers. She had cameo appearances in The Devil Wears Prada and Perfect Stranger.

In July 2007, having earned $8 million in the previous 12 months, Klum was named by Forbes as third on the list of the World's 15 Top-Earning Supermodels.[10] In 2008, Forbes estimated her income at $14 million, putting Klum in second place. For 2009, Forbes estimated her income at $16 million.[11] Klum is signed to IMG Models in New York City.

[edit]


Claire Catherine Danes (born April 12, 1979) is an American actress, perhaps best known for her role as Angela Chase in the television series My So-Called Life, and for starring in films such as Romeo + Juliet (as Juliet), Terminator 3: Rise of the Machines (as Kate Brewster) and Stardust (as Yvaine). She has received a Golden Globe Award and an Emmy nomination for My So-Called Life, and has also worked in theatre and as a voice actor (Princess Mononoke).

Contents

[hide]

[edit] Early life

Danes was born in Manhattan, New York City, New York.[1] Her mother, Carla, is a day-care provider, painter, and textile designer who later served as her daughter's manager, and her father, Christopher Danes, is a computer consultant and former architectural photographer. Danes has described her background as being "as WASPy as you can get";[2] her paternal grandfather, Gibson Andrew Danes, (1910-1992 in Litchfield, Connecticut) was the dean of the art and architecture school at Yale University.[3][4] She has an older brother, Asa, who graduated from Oberlin College and works as a litigation attorney for the law firm of Paul Hastings.

Danes attended the Dalton School in New York City, the New York City Lab School for Collaborative Studies, the Professional Performing Arts School,[5] and the Lycée Français de Los Angeles in Los Angeles, California. In 1998, Danes went to Yale University, her father's alma mater. Oliver Stone wrote her letter of recommendation to Yale.[5] After studying for two years as a psychology major, she dropped out of Yale to focus on her film career.

[edit] Career

Danes in Toronto for a MuchOnDemand in promotion of Stardust, 2007.

In 1994, 15-year-old Danes starred as the 15-year-old Angela Chase in the television drama series My So-Called Life, for which she won a Golden Globe Award and received an Emmy nomination. She played Elizabeth "Beth" March in the 1994 movie adaptation of Little Women. She also appeared as Holly Hunter's daughter in Home for the Holidays, which was directed by Jodie Foster. She portrayed Juliet Capulet in Baz Luhrmann's 1996 film William Shakespeare's Romeo + Juliet, co-starring Leonardo DiCaprio as Romeo Montague. Later that year, she was credited to the popular belief that she'd turned down the lead role in Titantic but in a 2009 interview Danes claimed she doesn't know how the rumour started saying 'someone must have put it on wikipedia' and that she had been considered but she was never offered the role. In 1999, she made her first appearance in an animated feature with the English version of Princess Mononoke, and took the lead role in Brokedown Palace, alongside Kate Beckinsale and Bill Pullman.

In 2002, Danes starred alongside Susan Sarandon, Kieran Culkin, and Bill Pullman again, in Igby Goes Down. She later co-starred as Meryl Streep's daughter in the Oscar-nominated, The Hours, with Nicole Kidman, Julianne Moore, and Ed Harris. The following year, she was cast in Terminator 3: Rise of the Machines, followed by Stage Beauty in 2004. She earned critical acclaim in 2005 when she starred in Steve Martin's Shopgirl alongside Martin and Jason Schwartzman, and in The Family Stone opposite Sarah Jessica Parker and Diane Keaton. In 2007, Danes appeared in the fantasy Stardust, which she described as a "classic model of romantic comedy",[6] with Charlie Cox, Michelle Pfeiffer, Robert De Niro, and Sienna Miller, and appeared in The Flock, opposite Richard Gere.

Danes appeared in Off-Broadway plays including Happiness, Punk Ballet, and Kids On Stage, in which she choreographed her own solo dance. She also wrote the introduction to Neil Gaiman's Death: The Time of Your Life. Danes auditioned for the role of Lois Lane in Superman Returns before the role went to Kate Bosworth.

In March 2007, Danes appeared with Patrick Wilson in a television commercial for Gap in which the pair dances to the song " Anything You Can Do" from the musical Annie Get Your Gun. Danes has recently appeared onstage at Manhattan's PS122 an avant-garde performance space, in a series of dance pieces by choreographer Tamar Rogoff. Danes made her stage debut at PS122 as a child.[7]

On October 19, 2007, Danes made her Broadway debut in the revival of George Bernard Shaw's Pygmalion, starring as Eliza Doolittle.[8]


Angelina Jolie (born Angelina Jolie Voight; June 4, 1975) is an American actress. She has received three Golden Globe Awards, two Screen Actors Guild Awards, and an Academy Award. Jolie has promoted humanitarian causes throughout the world, and is noted for her work with refugees through as a Goodwill Ambassador for the United Nations High Commissioner for Refugees (UNHCR). She has been cited as one of the world's most beautiful women and her off-screen life is widely reported.[1]

Though she made her screen debut as a child alongside her father Jon Voight in the 1982 film Lookin' to Get Out, Jolie's acting career began in earnest a decade later with the low-budget production Cyborg 2 (1993). Her first leading role in a major film was in Hackers (1995). She starred in the critically acclaimed biographical films George Wallace (1997) and Gia (1998), and won an Academy Award for Best Supporting Actress for her performance in the drama Girl, Interrupted (1999). Jolie achieved wider fame after her portrayal of video game heroine Lara Croft in Lara Croft: Tomb Raider (2001), and since then has established herself as one of the best-known and highest-paid actresses in Hollywood.[2] She has had her biggest commercial successes with the action-comedy Mr. & Mrs. Smith (2005) and the animated film Kung Fu Panda (2008).[3]

Divorced from actors Jonny Lee Miller and Billy Bob Thornton, Jolie currently lives with actor Brad Pitt, in a relationship that has attracted worldwide media attention. Jolie and Pitt have three adopted children, Maddox, Pax, and Zahara, as well as three biological children, Shiloh, Knox, and Vivienne.

Contents

[hide]

Early life and family

Born in Los Angeles, California, Jolie is the daughter of actors Jon Voight and Marcheline Bertrand. She is the niece of Chip Taylor, sister of James Haven and the god-daughter of Jacqueline Bisset and Maximilian Schell. On her father's side, Jolie is of Czechoslovakian and German descent,[4][5] and on her mother's side she is French Canadian and is said to be part Iroquois.[6][7] However, Voight has claimed Bertrand was "not seriously Iroquois", and they merely said it to enhance his ex-wife's exotic background.[8]

After her parents' separation in 1976, Jolie and her brother were raised by their mother, who abandoned her acting ambitions and moved with them to Palisades, New York.[9] As a child, Jolie regularly saw movies with her mother and later explained that this had inspired her interest in acting; she had not been influenced by her father.[10] When she was eleven years old, the family moved back to Los Angeles and Jolie decided she wanted to act and enrolled at the Lee Strasberg Theatre Institute, where she trained for two years and appeared in several stage productions.

At the age of 14, she dropped out of her acting classes and dreamed of becoming a funeral director.[11] During this period, she wore black clothing, dyed her hair purple and went out moshing with her live-in boyfriend.[10] Two years later, after the relationship had ended, she rented an apartment above a garage a few blocks from her mother's home.[9] She returned to theatre studies and graduated from high school, though in recent times she has referred to this period with the observation, "I am still at heart—and always will be—just a punk kid with tattoos".[12]

She later recalled her time as a student at Beverly Hills High School (later Moreno High School), and her feeling of isolation among the children of some of the area's more affluent families. Jolie's mother survived on a more modest income, and Jolie often wore second-hand clothes. She was teased by other students who also targeted her for her distinctive features, for being extremely thin, and for wearing glasses and braces.[10] Her self-esteem was further diminished when her initial attempts at modeling proved unsuccessful. She started to cut herself; later commenting, "I collected knives and always had certain things around. For some reason, the ritual of having cut myself and feeling the pain, maybe feeling alive, feeling some kind of release, it was somehow therapeutic to me."[13]

Jolie has been long estranged from her father. The two tried to reconcile and he appeared with her in Lara Croft: Tomb Raider (2001).[9] In July 2002, Jolie filed a request to legally change her name to "Angelina Jolie", dropping Voight as her surname; the name change was made official on September 12, 2002.[14] In August of the same year, Voight claimed that his daughter had "serious mental problems" on Access Hollywood. Jolie later indicated that she no longer wished to pursue a relationship with her father, and said, "My father and I don't speak. I don't hold any anger toward him. I don't believe that somebody's family becomes their blood. Because my son's adopted, and families are earned." She stated that she did not want to publicize her reasons for her estrangement from her father, but because she had adopted her son, she did not think it was healthy for her to associate with Voight.[15]



Amanda Peet (born January 11, 1972) is an American actress.

After studying with Uta Hagen, Peet began her career in television commercials, and progressed to small roles in television and indie movies. Featured roles in films such as The Whole Nine Yards (2000) brought her recognition and she was named one of People's "50 Most Beautiful People in the World". Her subsequent film roles have been more prominent, and include Something's Gotta Give (2003), Syriana (2005), and 2012 (2009).

Contents

[hide]

[edit] Life and career

[edit] Early life

Peet was born in New York City, the daughter of Penny (née Levy), a social worker, and Charles Peet, a corporate lawyer.[1] The two are now divorced. Her father is a Quaker and her mother is Jewish.[2][3] Peet attended Friends Seminary, then studied history at and graduated from Columbia University,[4] where she auditioned for acting teacher Uta Hagen and decided to become an actress after taking Hagen's class.[5] During her four-year period of study with Hagen, Peet appeared in the off-Broadway revival of Clifford Odets's Awake and Sing.

[edit] Career

Peet's first screen performance was a television commercial for Skittles. Her early roles included a guest role on the television series Law & Order. She made her film debut in Animal Room (1995). Peet maintained a steady acting career in relatively obscure indie movies.

Her first major role was as "Jack" in the 1999 WB network series Jack & Jill (which aired for two seasons). She also appeared in the eighth-season finale of Seinfeld ("The Summer of George") as a waitress whom Jerry Seinfeld meets. Peet's first role in a widely-released feature film came in 2000, with The Whole Nine Yards, starring with Bruce Willis. That same year, she was voted one of the 50 Most Beautiful People in the World by People magazine. Peet was also in the movie Saving Silverman with Jason Biggs, Jack Black and Steve Zahn, where she portrayed psychologist Judith. She also starred in Something's Gotta Give in 2003, playing Diane Keaton's daughter, and, at one point, Jack Nicholson's girlfriend.

In 2005, Peet appeared in the play This Is How It Goes, filling in for Marisa Tomei at the last minute after six days of rehearsal. In the same year, she also co-starred in the films Syriana alongside Matt Damon and George Clooney, and A Lot Like Love, with Ashton Kutcher. In February 2006, she was performing in Neil Simon's Broadway production of Barefoot in the Park.

Peet was a member of the cast of the television series Studio 60 on the Sunset Strip, which premiered on NBC on September 18, 2006. She starred with Matthew Perry, with whom she worked in The Whole Nine Yards and The Whole Ten Yards, and Sarah Paulson, with whom she co-starred in Jack & Jill. In Studio 60, Peet's character Jordan McDeere was the newly-appointed president of the National Broadcasting System (NBS). In 2006, she also starred along with Dermot Mulroney in Griffin and Phoenix, where she played a terminally-ill woman living life to the fullest.

In 2007's The Ex, a comedy co-starring Zach Braff, Peet played an attorney who stays home to raise a new baby. In 2008, Peet went on to play an FBI agent in The X-Files: I Want to Believe.[6]

Peet starred as Kate in 2012, a disaster film directed by Roland Emmerich and released on November 13, 2009.

[edit] Personal life

Peet married screenwriter David Benioff on September 30, 2006, in New York City[7] and gave birth to a daughter, Frances Pen, on February 20, 2007.[8] The three live in Manhattan and Beverly Hills. She was also maid of honor at Lauren Holly's marriage in 2001 with Francis Greco.

On December 10, 2009 she announced that she and David would be expecting their second child. [9]

In 2008 Peet volunteered to be a spokeswoman for Every Child By Two (ECBT), a non-profit organization which advocates childhood vaccination. Peet began working with the group after becoming concerned by the "amount of misinformation floating around [about vaccines], particularly in Hollywood."[10] In an interview with Cookie, Peet stated: "Frankly, I feel that parents who don't vaccinate their children are parasites," referring to the benefit unvaccinated children derive from herd immunity and the concern that dropping vaccination rates may put all children at increased risk of preventable disease.[10] Peet's comments stirred controversy; in response, she apologized for using the term "parasites", but affirmed her position on the importance and safety of vaccination.[11][12]

[edit] Filmography

Thursday, January 29, 2009

How to: Define Value Equality for a Type (C# Programming)

When you define a class or struct, you
decide whether it makes sense to create a custom definition of value
equality (or equivalence) for the type. Typically, you implement value
equality when objects of the type are expected to be added to a
collection of some sort, or when their primary purpose is to store a
set of fields or properties. You can base your definition of value
equality on a comparison of all the fields and properties in the type,
or you can base the definition on a subset. But in either case, and in
both classes and structs, your implementation should follow the five
guarantees of equivalence:


  1. x.Equals(x) returns true. This is called the reflexive property.


  2. x.Equals(y) returns the same value as y.Equals(x). This is called the symmetric property.


  3. if (x.Equals(y) && y.Equals(z)) returns true, then x.Equals(z) returns true. This is called the transitive property.


  4. Successive invocations of x.Equals(y) return the same value as long as the objects referenced by x and y are not modified.


  5. x.Equals(null) returns false. However, null.Equals(null) throws an exception; it does not obey rule number two above.


Any struct that you define already has a default implementation of value equality that it inherits from the System..::.ValueType override of the Object..::.Equals(Object)
method. This implementation uses reflection to examine all the public
and non-public fields and properties in the type. Although this
implementation produces correct results, it is relatively slow compared
to a custom implementation that you write specifically for the type.

The implementation details for value equality
are different for classes and structs. However, both classes and
structs require the same basic steps for implementing equality:


  1. Override the virtual Object..::.Equals(Object) method. In most cases, your implementation of bool Equals( object obj ) should just call into the type-specific Equals method that is the implementation of the System..::.IEquatable<(Of <(T>)>) interface. (See step 2.)


  2. Implement the System..::.IEquatable<(Of <(T>)>) interface by providing a type-specific Equals
    method. This is where the actual equivalence comparison is performed.
    For example, you might decide to define equality by comparing only one
    or two fields in your type. Do not throw exceptions from Equals. For classes only: This method should examine only fields that are declared in the class. It should call base.Equals to examine fields that are in the base class. (Do not do this if the type inherits directly from Object, because the Object implementation of Object..::.Equals(Object) performs a reference equality check.)


  3. Optional but recommended: Overload the == and != operators.


  4. Override Object..::.GetHashCode so that two objects that have value equality produce the same hash code.


  5. Optional: To support definitions for "greater than" or "less than," implement the IComparable<(Of <(T>)>) interface for your type, and also overload the <= and >= operators.


The first example that follows shows a class implementation. The second
example shows a struct implementation.




The following example shows how to implement value equality in a class (reference type).

<span style="color: blue;">namespace</span> ValueEquality<br />{<br />    <span style="color: blue;">using</span> System;<br />    <span style="color: blue;">class</span> TwoDPoint : IEquatable<TwoDPoint><br />    {<br />        <span style="color: green;">// Readonly auto-implemented properties.</span><br />        <span style="color: blue;">public</span> <span style="color: blue;">int</span> X { <span style="color: blue;">get</span>; <span style="color: blue;">private</span> <span style="color: blue;">set</span>; }<br />        <span style="color: blue;">public</span> <span style="color: blue;">int</span> Y { <span style="color: blue;">get</span>; <span style="color: blue;">private</span> <span style="color: blue;">set</span>; }<br /><br />        <span style="color: green;">// Set the properties in the constructor.</span><br />        <span style="color: blue;">public</span> TwoDPoint(<span style="color: blue;">int</span> x, <span style="color: blue;">int</span> y)<br />        {<br />            <span style="color: blue;">if</span> ((x < 1) || (x > 2000) || (y < 1) || (y > 2000))<br />                throw <span style="color: blue;">new</span> System.ArgumentException(<span style="color: maroon;"><span style="color: maroon;">"Point must be in range 1 - 2000"</span></span>);<br />            <span style="color: blue;">this</span>.X = x;<br />            <span style="color: blue;">this</span>.Y = y;<br />        }<br /><br />        <span style="color: blue;">public</span> override <span style="color: blue;">bool</span> Equals(object obj)<br />        {<br />            <span style="color: blue;">return</span> <span style="color: blue;">this</span>.Equals(obj as TwoDPoint);<br />        }<br /><br />        <span style="color: blue;">public</span> <span style="color: blue;">bool</span> Equals(TwoDPoint p)<br />        {<br />            <span style="color: green;">// If parameter is null, return false.</span><br />            <span style="color: blue;">if</span> (Object.ReferenceEquals(p, <span style="color: blue;">null</span>))<br />            {<br />                <span style="color: blue;">return</span> <span style="color: blue;">false</span>;<br />            }<br /><br />            <span style="color: green;">// Optimization for a common success case.</span><br />            <span style="color: blue;">if</span> (Object.ReferenceEquals(<span style="color: blue;">this</span>, p))<br />            {<br />                <span style="color: blue;">return</span> <span style="color: blue;">true</span>;<br />            }<br /><br />            <span style="color: green;">// If run-time types are not exactly the same, return false.</span><br />            <span style="color: blue;">if</span> (<span style="color: blue;">this</span>.GetType() != p.GetType())<br />                <span style="color: blue;">return</span> <span style="color: blue;">false</span>;<br /><br />            <span style="color: green;">// Return true if the fields match.</span><br />            <span style="color: green;">// Note that the base class is not invoked because it is</span><br />            <span style="color: green;">// System.Object, which defines Equals as reference equality.</span><br />            <span style="color: blue;">return</span> (X == p.X) && (Y == p.Y);<br />        }<br /><br />        <span style="color: blue;">public</span> override <span style="color: blue;">int</span> GetHashCode()<br />        {<br />            <span style="color: blue;">return</span> X * 0x00010000 + Y;<br />        }<br /><br />        <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">bool</span> operator ==(TwoDPoint lhs, TwoDPoint rhs)<br />        {<br />            <span style="color: green;">// Check for null on left side.</span><br />            <span style="color: blue;">if</span> (Object.ReferenceEquals(lhs, <span style="color: blue;">null</span>))<br />            {<br />                <span style="color: blue;">if</span> (Object.ReferenceEquals(rhs, <span style="color: blue;">null</span>))<br />                {<br />                    <span style="color: green;">// null == null = true.</span><br />                    <span style="color: blue;">return</span> <span style="color: blue;">true</span>;<br />                }<br /><br />                <span style="color: green;">// Only the left side is null.</span><br />                <span style="color: blue;">return</span> <span style="color: blue;">false</span>;<br />            }<br />            <span style="color: green;">// Equals handles case of null on right side.</span><br />            <span style="color: blue;">return</span> lhs.Equals(rhs);<br />        }<br /><br />        <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">bool</span> operator !=(TwoDPoint lhs, TwoDPoint rhs)<br />        {<br />            <span style="color: blue;">return</span> !(lhs == rhs);<br />        }<br />    }<br /><br />    <span style="color: green;">// For the sake of simplicity, assume a ThreeDPoint IS a TwoDPoint.</span><br />    <span style="color: blue;">class</span> ThreeDPoint : TwoDPoint, IEquatable<ThreeDPoint><br />    {<br />        <span style="color: blue;">public</span> <span style="color: blue;">int</span> Z { <span style="color: blue;">get</span>; <span style="color: blue;">private</span> <span style="color: blue;">set</span>; }<br /><br />        <span style="color: blue;">public</span> ThreeDPoint(<span style="color: blue;">int</span> x, <span style="color: blue;">int</span> y, <span style="color: blue;">int</span> z)<br />            : <span style="color: blue;">base</span>(x, y)<br />        {<br />            <span style="color: blue;">if</span> ((z < 1) || (z > 2000))<br />                throw <span style="color: blue;">new</span> System.ArgumentException(<span style="color: maroon;"><span style="color: maroon;">"Point must be in range 1 - 2000"</span></span>);<br />            <span style="color: blue;">this</span>.Z = z;<br />        }<br /><br />        <span style="color: blue;">public</span> override <span style="color: blue;">bool</span> Equals(object obj)<br />        {<br />            <span style="color: blue;">return</span> <span style="color: blue;">this</span>.Equals(obj as ThreeDPoint);<br />        }<br /><br />        <span style="color: blue;">public</span> <span style="color: blue;">bool</span> Equals(ThreeDPoint p)<br />        {<br />            <span style="color: green;">// If parameter is null, return false.</span><br />            <span style="color: blue;">if</span> (Object.ReferenceEquals(p, <span style="color: blue;">null</span>))<br />            {<br />                <span style="color: blue;">return</span> <span style="color: blue;">false</span>;<br />            }<br /><br />            <span style="color: green;">// Optimization for a common success case.</span><br />            <span style="color: blue;">if</span>(Object.ReferenceEquals(<span style="color: blue;">this</span>, p))<br />            {<br />                <span style="color: blue;">return</span> <span style="color: blue;">true</span>;<br />            }<br /><br />            <span style="color: green;">// Check properties that this class declares.</span><br />            <span style="color: blue;">if</span> (Z == p.Z)<br />            {<br />                <span style="color: green;">// Let base class check its own fields </span><br />                <span style="color: green;">// and do the run-time type comparison.</span><br />                <span style="color: blue;">return</span> <span style="color: blue;">base</span>.Equals((TwoDPoint)p);<br />            }<br />            <span style="color: blue;">else</span><br />                <span style="color: blue;">return</span> <span style="color: blue;">false</span>;<br />        }<br /><br />        <span style="color: blue;">public</span> override <span style="color: blue;">int</span> GetHashCode()<br />        {<br />            <span style="color: blue;">return</span> (X * 0x100000) + (Y * 0x1000) + Z;<br />        }<br /><br />        <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">bool</span> operator ==(ThreeDPoint lhs, ThreeDPoint rhs)<br />        {<br />            <span style="color: green;">// Check for null.</span><br />            <span style="color: blue;">if</span> (Object.ReferenceEquals(lhs, <span style="color: blue;">null</span>))<br />            {<br />                <span style="color: blue;">if</span> (Object.ReferenceEquals(lhs, <span style="color: blue;">null</span>))<br />                {<br />                    <span style="color: green;">// null == null = true.</span><br />                    <span style="color: blue;">return</span> <span style="color: blue;">true</span>;<br />                }<br /><br />                <span style="color: green;">// Only the left side is null.</span><br />                <span style="color: blue;">return</span> <span style="color: blue;">false</span>;<br />            }<br />            <span style="color: green;">// Equals handles the case of null on right side.</span><br />            <span style="color: blue;">return</span> lhs.Equals(rhs);<br />        }<br /><br />        <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">bool</span> operator !=(ThreeDPoint lhs, ThreeDPoint rhs)<br />        {<br />            <span style="color: blue;">return</span> !(lhs == rhs);<br />        }<br />    }<br /><br />    <span style="color: blue;">class</span> Program<br />    {<br />        <span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)<br />        {<br />            ThreeDPoint pointA = <span style="color: blue;">new</span> ThreeDPoint(3, 4, 5);<br />            ThreeDPoint pointB = <span style="color: blue;">new</span> ThreeDPoint(3, 4, 5);<br />            ThreeDPoint pointC = <span style="color: blue;">null</span>;<br />            <span style="color: blue;">int</span> i = 5;<br /><br />            Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"pointA.Equals(pointB) = {0}"</span></span>, pointA.Equals(pointB));<br />            Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"pointA == pointB = {0}"</span></span>, pointA == pointB);<br />            Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"null comparison = {0}"</span></span>, pointA.Equals(pointC));<br />            Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"Compare to some other type = {0}"</span></span>, pointA.Equals(i));<br /><br />            TwoDPoint pointD = <span style="color: blue;">null</span>;<br />            TwoDPoint pointE = <span style="color: blue;">null</span>;<br /><br /><br /><br />            Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"Two null TwoDPoints are equal: {0}"</span></span>, pointD == pointE);<br /><br />            pointE = <span style="color: blue;">new</span> TwoDPoint(3, 4);<br />            Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"(pointE == pointA) = {0}"</span></span>, pointE == pointA);<br />            Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"(pointA == pointE) = {0}"</span></span>, pointA == pointE);<br />            Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"(pointA != pointE) = {0}"</span></span>, pointA != pointE);<br /><br />            System.Collections.ArrayList list = <span style="color: blue;">new</span> System.Collections.ArrayList();<br />            list.Add(<span style="color: blue;">new</span> ThreeDPoint(3, 4, 5));<br />            Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"pointE.Equals(list[0]): {0}"</span></span>, pointE.Equals(list[0]));<br /><br />            <span style="color: green;">// Keep the console window open in debug mode.</span><br />            System.Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"Press any key to exit."</span></span>);<br />            System.Console.ReadKey();<br />        }<br />    }<br /><br />    <span style="color: green;">/* Output:<br />        pointA.Equals(pointB) = True<br />        pointA == pointB = True<br />        <span style="color: blue;">null</span> comparison = False<br />        Compare to some other type = False<br />        Two <span style="color: blue;">null</span> TwoDPoints are equal: True<br />        (pointE == pointA) = False<br />        (pointA == pointE) = False<br />        (pointA != pointE) = True<br />        pointE.Equals(list[0]): False<br />    */</span><br />}<br /><br /><br /></pre></div></div></div><p>
On classes (reference types), the default implementation of both <span><a id="ctl00_rs1_mainContentContainer_ctl42" onclick="javascript:Track('ctl00_rs1_mainContentContainer_cpe198786_c|ctl00_rs1_mainContentContainer_ctl42',this);" href="http://msdn.microsoft.com/en-us/library/bsc2ak47.aspx">Object<span class="cs">.</span><span class="vb">.</span><span class="cpp">::</span><span class="nu">.</span>Equals(Object)</a></span>
methods performs a reference equality comparison, not a value equality
check. When an implementer overrides the virtual method, the purpose is
to give it value equality semantics. </p><p>
The <span><span class="input">==</span></span> and <span><span class="input">!=</span></span>
operators can be used with classes even if the class does not overload
them. However, the default behavior is to perform a reference equality
check. In a class, if you overload the <span><span class="input">Equals</span></span> method, you should overload the <span><span class="input">==</span></span> and <span><span class="input">!=</span></span> operators, but it is not required.
</p><p>
The following example shows how to implement value equality in a struct (value type):
</p><div id="snippetGroup1"><div class="libCScode" id="ctl00_rs1_mainContentContainer_ctl44_CSharp"><div class="CodeSnippetTitleBar"><div class="CodeDisplayLanguage">C#</div><div class="CopyCodeButton"><a class="copyCode" title="Copy Code" href="javascript:CopyCode('ctl00_rs1_mainContentContainer_ctl44CSharp');"><img class="LibC_copy_off" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" align="middle" border="0" height="9" /> Copy Code</a></div></div><div dir="ltr"><pre class="libCScode" style="white-space: pre-wrap;" id="ctl00_rs1_mainContentContainer_ctl44CSharp" space="preserve"> struct TwoDPoint : IEquatable<TwoDPoint><br /> {<br /> <span style="color: green;">// Read/write auto-implemented properties.</span><br /> <span style="color: blue;">public</span> <span style="color: blue;">int</span> X { <span style="color: blue;">get</span>; <span style="color: blue;">private</span> <span style="color: blue;">set</span>; }<br /> <span style="color: blue;">public</span> <span style="color: blue;">int</span> Y { <span style="color: blue;">get</span>; <span style="color: blue;">private</span> <span style="color: blue;">set</span>; }<br /><br /> <span style="color: blue;">public</span> TwoDPoint(<span style="color: blue;">int</span> x, <span style="color: blue;">int</span> y) : <span style="color: blue;">this</span>()<br /> {<br /> X = x;<br /> Y = x;<br /> }<br /><br /> <span style="color: blue;">public</span> override <span style="color: blue;">bool</span> Equals(object obj)<br /> {<br /> <span style="color: blue;">if</span> (obj is TwoDPoint)<br /> {<br /> <span style="color: blue;">return</span> <span style="color: blue;">this</span>.Equals((TwoDPoint)obj);<br /> }<br /> <span style="color: blue;">return</span> <span style="color: blue;">false</span>;<br /> }<br /><br /> <span style="color: blue;">public</span> <span style="color: blue;">bool</span> Equals(TwoDPoint p)<br /> {<br /> <span style="color: blue;">return</span> (X == p.X) && (Y == p.Y);<br /> }<br /><br /> <span style="color: blue;">public</span> override <span style="color: blue;">int</span> GetHashCode()<br /> {<br /> <span style="color: blue;">return</span> X ^ Y;<br /> }<br /><br /> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">bool</span> operator ==(TwoDPoint lhs, TwoDPoint rhs)<br /> {<br /> <span style="color: blue;">return</span> lhs.Equals(rhs);<br /> }<br /><br /> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">bool</span> operator !=(TwoDPoint lhs, TwoDPoint rhs)<br /> {<br /> <span style="color: blue;">return</span> !(lhs.Equals(rhs));<br /> }<br /> }<br /><br /><br /> <span style="color: blue;">class</span> Program<br /> {<br /> <span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)<br /> {<br /> TwoDPoint pointA = <span style="color: blue;">new</span> TwoDPoint(3,4);<br /> TwoDPoint pointB = <span style="color: blue;">new</span> TwoDPoint(3,4);<br /> <span style="color: blue;">int</span> i = 5;<br /><br /> <span style="color: green;">// Compare using virtual Equals, static Equals, and == and != operators.</span><br /> <span style="color: green;">// True:</span><br /> Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"pointA.Equals(pointB) = {0}"</span></span>, pointA.Equals(pointB));<br /> <span style="color: green;">// True:</span><br /> Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"pointA == pointB = {0}"</span></span>, pointA == pointB);<br /> <span style="color: green;">// True:</span><br /> Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"Object.Equals(pointA, pointB) = {0}"</span></span>, Object.Equals(pointA, pointB)); <br /> <span style="color: green;">// False:</span><br /> Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"pointA.Equals(null) = {0}"</span></span>, pointA.Equals(<span style="color: blue;">null</span>));<br /> <span style="color: green;">// False:</span><br /> Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"(pointA == null) = {0}"</span></span>, pointA == <span style="color: blue;">null</span>);<br /> <span style="color: green;">// True:</span><br /> Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"(pointA != null) = {0}"</span></span>, pointA != <span style="color: blue;">null</span>);<br /> <span style="color: green;">// False:</span><br /> Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"pointA.Equals(i) = {0}"</span></span>, pointA.Equals(i)); <br /> <span style="color: green;">// CS0019:</span><br /> <span style="color: green;">// Console.WriteLine("pointA == i = {0}", pointA == i); </span><br /><br /> <span style="color: green;">// Compare unboxed to boxed.</span><br /> System.Collections.ArrayList list = <span style="color: blue;">new</span> System.Collections.ArrayList();<br /> list.Add(<span style="color: blue;">new</span> TwoDPoint(3,4));<br /> <span style="color: green;">// True:</span><br /> Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"pointE.Equals(list[0]): {0}"</span></span>, pointA.Equals(list[0])); <br /><br /><br /> <span style="color: green;">// Compare nullable to nullable and to non-nullable.</span><br /> TwoDPoint? pointC = <span style="color: blue;">null</span>;<br /> TwoDPoint? pointD = <span style="color: blue;">null</span>;<br /> <span style="color: green;">// False:</span><br /> Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"pointA == (pointC = null) = {0}"</span></span>, pointA == pointC);<br /> <span style="color: green;">// True:</span><br /> Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"pointC == pointD = {0}"</span></span>, pointC == pointD); <br /><br /> TwoDPoint temp = <span style="color: blue;">new</span> TwoDPoint(3,4);<br /> pointC = temp;<br /> <span style="color: green;">// True:</span><br /> Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"pointA == (pointC = 3,4) = {0}"</span></span>, pointA == pointC); <br /><br /> pointD = temp;<br /> <span style="color: green;">// True:</span><br /> Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"pointD == (pointC = 3,4) = {0}"</span></span>, pointD == pointC); <br /><br /> <span style="color: green;">// Keep the console window open in debug mode.</span><br /> System.Console.WriteLine(<span style="color: maroon;"><span style="color: maroon;">"Press any key to exit."</span></span>);<br /> System.Console.ReadKey();<br /> }<br /> }<br /><br /> <span style="color: green;">/* Output:<br /> pointA.Equals(pointB) = True<br /> pointA == pointB = True<br /> Object.Equals(pointA, pointB) = True<br /> pointA.Equals(<span style="color: blue;">null</span>) = False<br /> (pointA == <span style="color: blue;">null</span>) = False<br /> (pointA != <span style="color: blue;">null</span>) = True<br /> pointA.Equals(i) = False<br /> pointE.Equals(list[0]): True<br /> pointA == (pointC = <span style="color: blue;">null</span>) = False<br /> pointC == pointD = True<br /> pointA == (pointC = 3,4) = True<br /> pointD == (pointC = 3,4) = True<br /> */</span><br />}<br /><br />


For structs, the default implementation of Object..::.Equals(Object) (which is the overridden version in System..::.ValueType)
performs a value equality check by using reflection to compare the
values of every field in the type. When an implementer overrides the
virtual Equals method in a
stuct, the purpose is to provide a more efficient means of performing
the value equality check and optionally to base the comparison on some
subset of the struct's field or properties.


The == and != operators cannot operate on a struct unless the struct explicitly overloads them.