|
Steve, this is a good point. I have to think about it a little more, but as you have explained it, static methods may well be a good compromise between procedural and class-based languages. And once you have the syntax, then you just need to add a variable type of "object" to each procedural language, and an interface to garbage collection, and you can move into OO pretty seamlessly. Interesting... Joe > From: Steve Richter > > I had the same reaction. "static" methods are the equivalent of > standalone procedures. The .NET Convert class is a good example of a > static class. > http://msdn.microsoft.com/library/en- > us/cpref/html/frlrfSystemConvertClassTopic.asp?frame=true > > To convert a string to an integer: > int PortNx ; > string PortNumber = "23" ; > PortNx = System.Convert.ToInt32( PortNumber ) ; > > this static method converts a base64 encoded string to an array of bytes: > byte[] results = System.Convert.FromBase64String( ResponseData ) ; > > The DateTime class has a bunch of good static methods: > DateTime beginRun = DateTime.Now ; // the current timestamp > DateTime endRun = DateTime.UtcNow ; // the current UTC timestamp. > > The advantage of static class methods over standalone procedures is > you can make your statics either public or private. You organize the > statics in a class ( really a namespace ). Users of your class only > see the public methods. To structure your code you have a bunch of > private static methods that do a lot of the work, only users of the > class dont have to see those methods. > > -Steve
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.