How to use class with private constructors?

Posted by DenDuze on 08-Apr-2016 06:22

Hi,


This is a problem that I had a few times and I would like to know how to solve that in the future.
If a class has private  constructor(s) (example: System.Globalization.Calendar) then I can't use that.


if I try
message System.Globalization.Calendar:GetDayOfMonth(today) view-as alert-box.
I get error 14633 ==> must use an object-instance, not the class itself

When I try to create an object instance i get error 15107 ==> you cannot create an instance of because it's an abstract class.

So how can I use that System.Globalization.Calendar class in Progress?

Thanks

Didier

Posted by marian.edu on 08-Apr-2016 06:58

Stop guessing and instead of the class browser go straight to the msdn site for .not documentation :)

https://msdn.microsoft.com/en-us/library/ff361664(v=vs.110).aspx




Sent from outer space
On 08 Apr 2016, at 14:52, DenDuze <bounce-DenDuze@community.progress.com> wrote:

<ProgressEmailLogo-png_2D00_150x42x2-png> Update from Progress Community
DenDuze

Hi Marian, Mike,

Thanks, That makes sense but how do you know - from the Class Browser -  what classes have implemented this abstract class.

I can guess by the name but I also guess that's not garanteed (it's best practice but not mandatory - or is it).

Thanks, I can test further ...

View online

 

You received this notification because you subscribed to the forum.  To unsubscribe from only this thread, go here.

Flag this post as spam/abuse.

Posted by Mike Fechner on 08-Apr-2016 06:33

The Calendar class is abstract and GetDayOfMonth is an abstract method.

You will have to use an actual calendar implementation like the gregorian calendar or  

DEFINE VARIABLE oCalendar AS System.Globalization.Calendar NO-UNDO. .
oCalendar = NEW System.Globalization.GregorianCalendar ().
MESSAGE oCalendar:GetDayOfMonth (TODAY).

All Replies

Posted by Mike Fechner on 08-Apr-2016 06:33

The Calendar class is abstract and GetDayOfMonth is an abstract method.

You will have to use an actual calendar implementation like the gregorian calendar or  

DEFINE VARIABLE oCalendar AS System.Globalization.Calendar NO-UNDO. .
oCalendar = NEW System.Globalization.GregorianCalendar ().
MESSAGE oCalendar:GetDayOfMonth (TODAY).

Posted by marian.edu on 08-Apr-2016 06:34

Than’s because it’s an abstract class, you might try some of the available implementations like GregorianCalendar that has a public constructor.



Marian Edu

Acorn IT 
+40 740 036 212

Posted by Mike Fechner on 08-Apr-2016 06:40

Actually even better should be:

oCalendar = System.Globalization.CultureInfo:CurrentCulture:Calendar.

Posted by DenDuze on 08-Apr-2016 06:50

Hi Marian, Mike,

Thanks, That makes sense but how do you know - from the Class Browser -  what classes have implemented this abstract class.

I can guess by the name but I also guess that's not garanteed (it's best practice but not mandatory - or is it).

Thanks, I can test further ...

Posted by marian.edu on 08-Apr-2016 06:58

Stop guessing and instead of the class browser go straight to the msdn site for .not documentation :)

https://msdn.microsoft.com/en-us/library/ff361664(v=vs.110).aspx




Sent from outer space
On 08 Apr 2016, at 14:52, DenDuze <bounce-DenDuze@community.progress.com> wrote:

<ProgressEmailLogo-png_2D00_150x42x2-png> Update from Progress Community
DenDuze

Hi Marian, Mike,

Thanks, That makes sense but how do you know - from the Class Browser -  what classes have implemented this abstract class.

I can guess by the name but I also guess that's not garanteed (it's best practice but not mandatory - or is it).

Thanks, I can test further ...

View online

 

You received this notification because you subscribed to the forum.  To unsubscribe from only this thread, go here.

Flag this post as spam/abuse.

This thread is closed