Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class Foo
- {
- public int ID = 123;
- public string Name = "SomeName";
- private string ToString() { return null; }
- }
- public class MyClass
- {
- public static void Main()
- {
- Foo myObj = new Foo();
- WL("I want this to be a compiler error: {0}", myObj.ToString());
- RL();
- }
- #region Helper methods
- private static void WL(object text, params object[] args)
- {
- Console.WriteLine(text.ToString(), args);
- }
- private static void RL()
- {
- Console.ReadLine();
- }
- #endregion
- }
- [Obsolete("Use the XYZ properties instead of .ToString() on Foobar", true)]
- [Obsolete("dont' use", true)]
- public override string ToString()
- {
- throw new Exception("don't use");
- }
- Foo myObj = new Foo();
- Console.WriteLine(myObj);
- public string CreateItemUrl(int itemId)
- {
- return string.Format("someurl.aspx?id={0}", itemId);
- }
- CreateItemUrl(myObj.Id);
- string theUrl = string.Format("someurl.aspx?id={0}", myObj);
- public new void ToString() { }
Add Comment
Please, Sign In to add comment