Click here to Skip to main content
15,881,719 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I study a class and wonder how this class can be used. it does not have public constructor:

public sealed class Convert
{
    public System.Drawing.PointF ToGDI(Sharp3D.Math.Core.Vector2F value)
    {
        return new System.Drawing.PointF(value.X, value.Y);
    }
    public Sharp3D.Math.Core.Vector2F FromGDI(System.Drawing.PointF value)
    {
        return new Sharp3D.Math.Core.Vector2F(value.X, value.Y);
    }

    #region Private Constructor
    private Convert()
    {
    }
    #endregion
}


What I have tried:

I understand this private constructor will block user to instantiate this class, but this class does not have other parametric constructor to use, so what is the use of this class?
Posted
Updated 18-Jun-22 11:31am

None whatsoever, that I can see.
It can't be instantiated, it can't be inherited, it doesn't contain any static field, properties, or methods.
You can't even use dependency injection with it, as far as I know.

To me, it looks like a singleton class that is lacking the singleton accessor / storage.

[edit]
Thinking about it, you would be able to instantiate it via Reflection, but that does seem like a fairly dumb idea for any practical purpose.
[/edit]
 
Share this answer
 
v2
Comments
Southmountain 18-Jun-22 17:27pm    
thanks for your time. now I feel more assured about my understanding,,,
As presented, it can't really do anything. Are you sure there is no other code?

Such a class could have a factory method, but that one seems not to.

Possibly it was meant to be a static class.
 
Share this answer
 
Comments
Southmountain 18-Jun-22 18:35pm    
there are other codes, but for this class, it's all.

thanks for your answer!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900