Thursday, August 27, 2015

C# Overloading

Simple class file created to display how overloading works in C#.
The following example was done in LINQPad

Overloading Example: (https://www.youtube.com/watch?v=cN7ZlpJsAnQ)

class Class1
{
 public int Num1 = 0;

 public static  Class1 operator +(Class1 obj1, Class1 obj2)
{
Class1 obj3 = new Class1();
obj3.Num1 = obj1.Num1 + obj2.Num1;
return obj3;
}
}

void Main()
{
Class1 obj1 = new Class1();
obj1.Num1 = 10;

Class1 obj2 = new Class1();
obj2.Num1 = 10;

Class1 obj3 = new Class1();
obj3 = obj1 + obj2;

Console.WriteLine("The value of obj3 is: {0}",obj3.Num1);
}

Thursday, August 20, 2015

Python calling function within a class from another class from Visual Studio

The following example listed below was done using Visual Studio Visual Studio. https://www.visualstudio.com/en-us/features/python-vs.aspx

The scope of this example was create a python file and call a function within a class file from the __init__, the init is the constructor for a class.  Then passing in the variables to set locally within the class file.

PythonApplication.py:
import sys
import pClass

def main():
    print "test"

def anothermain():
    thisClass = pClass.pClass("Lino","39","1")
    #del thisClass # this is how to use the destructor in python
    pClass.pClass.aClass(thisClass)
    print "testing"

if __name__ == "__main__":
    main()
    anothermain()

ClassFile.py:
class pClass(object):
 
    def __init__(self, name,age,net):#,*args, **kwargs):
        self.name = name
        self.age = age
        self.net = net
        self.aClass()
 
    def aClass(object):
        print "Name is %s, age is %s, net worth is %s" % (object.name, object.age, object.net) #(self.name, self.age, self.net)