Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
T

Tony Lambert

@Tony Lambert
About
Posts
12
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • about C#
    T Tony Lambert

    > Here if both base class has one common method say Method1().Now,during execution if derived class excess Method1(),then derived class will get confuse Not really. :-) This problem has already been solved at a same matter with multiple inheritance interfaces. It could be solved (IMHO with more willing). For example:

    class base1
    {
    void Method()
    {
    DoSomethingGood();
    }
    }

    class base2
    {
    void Method()
    {
    DoSomethingVeryGood();
    }
    }

    class derive : base1, base2
    {
    new void base1.Method()
    {
    DoSomethingBad();
    }
    new void base2.Method()
    {
    DoSomethingVeryBad();
    }
    }

    C# csharp oop

  • Object creation at internal condition in constructor
    T Tony Lambert

    :)

    C# help tutorial question

  • Object creation at internal condition in constructor
    T Tony Lambert

    "An exception buffer? Why do you think that?" call stack :) Thanks Guffa. I think you're right, it comes back with object reference. BTW, I've solved this issue across a static init method, where I do the try/cacth as well before the instance gets created. The constructor is hidden now. :-)

    C# help tutorial question

  • Object creation at internal condition in constructor
    T Tony Lambert

    It is the same without catch (first example). When I throw an exception it only gets registered in an exception buffer till something catches. It does nothing with the constructor itself. That is the reason why it comes back with not null value all the time. :( When I don't catch it, the application gets killed at the exit point of constuctor. That's another problem: I need that null value. :( Anyway, somebody has given to me another solution with indirect static method initialisation in the next thread. I think I'll do it that way. :doh: Thanks to All again. :)

    C# help tutorial question

  • Object creation at internal condition in constructor
    T Tony Lambert

    Thanks again. Here is a simple code: using System; public class ConditionalObject { public ConditionalObject(string name) { try { if (name.Equals("")) { throw new ArgumentOutOfRangeException(this.ToString() + ": Unable to create new object without identifier."); } } catch (ArgumentOutOfRangeException AException) { Console.WriteLine(AException.Message); } } } public class CallerClass { public static void Main() { ConditionalObject obj = new ConditionalObject(""); Console.WriteLine(obj == null ? "null" : "not null"); } } When I change this: ConditionalObject obj = new ConditionalObject(""); to this: ConditionalObject obj = new ConditionalObject("anything"); the last line gives the same value (not null). What did I wrong? :doh:

    C# help tutorial question

  • Object creation at internal condition in constructor
    T Tony Lambert

    "Remove it and only accept calls to constructors that initialize the fields you need set." Well it is okay in end user application, but it's an abstract class in library. Since it will be called by end-developers, the API must be consistent and any internal operation must to be transparent to make the library clear, and understandable.

    C# help tutorial question

  • Object creation at internal condition in constructor
    T Tony Lambert

    Thanks Luc. I wait for a while than I'll try to solve it this way. :)

    C# help tutorial question

  • Object creation at internal condition in constructor
    T Tony Lambert

    I do nothing with it. (should I? :doh:) I just throw it, it raises the exception message and the constructor returns with the object reference in the caller method instead of null. Actually, this is the missing part of the puzzle: how to destroy or give null operand to the object in its constructor or mark it as destroyable or return with null? :(

    C# help tutorial question

  • Object creation at internal condition in constructor
    T Tony Lambert

    Thanks ejuanpp. Not a bad idea, but I'll be in the same problem: end-developers need to handle it externally or do some kind of validation afterwards and the API will not be consistent. :( I'd like to avoid to leave the default object creation way or do anything "non-standard" to make easier other developers life. :)

    C# help tutorial question

  • Object creation at internal condition in constructor
    T Tony Lambert

    Thanks Guffa. Unfortunatelly this is the main problem: it returns the (not null) object reference whatever I've thrown exception or not. :( It is a quite big problem because I couldn't even check the previously unidentified object in the next line externally. Is there any other way to solve this?

    C# help tutorial question

  • need a Network Programming with VC#2005 pdf,Ebook,article.
    T Tony Lambert

    There are plenty of examples on the internet. You need to learn about socket programming. Use "System.Net.Sockets" or check out this project: http://www.codeplex.com/IndySockets It is still under work but the developers are professionals in socket programming, so download the snapshots and you can learn a lot. :) This is the original Indy Sockets written in Delphi, but runs on .NET as well: http://www.indyproject.org/Sockets/index.en.aspx

    C# sysadmin csharp help question learning

  • Object creation at internal condition in constructor
    T Tony Lambert

    Hi All, I'm having an issue with constructors. I want to prevent the creation internally in the following example: using System; public class ConditionalObject { private string _MajorName; private string _MinorName; public string MajorName { get { return _MajorName; } } public string MinorName { get { return _MinorName; } } public ConditionalObject() { if ((_MajorName.Length == 0) || (_MinorName.Length == 0)) { throw new Exception("Unable to initialise new object without identifier."); /******* what to do here to be destroyed? *******/ } } public ConditionalObject(string AMajorName, string AMinorName): base() { _MajorName = AMajorName; _MinorName = AMinorName; } } Neither Dispose(); nor return null; nor this = null; can be applied in constructor. Could anybody help me guys? Thanks for the answers. :)

    C# help tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups