Posts

Practical 9 - Create a simple Web service get a GET and POST endpoint for greetings

Create New WebSite Project in Visual Studio. Right click on the Solution explorer and Add New Item and Choose Web Service and save file. Write the following code in the file created and run it to test.   Webservice.cs using  System;   using  System.Collections.Generic;   using  System.Web;   using  System.Web.Services;   ///<summary>    /// Summary description for UtilityWebService    ///</summary>    [WebService(Namespace =  "http://tempuri.org/" )]   [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]   // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.     // [System.Web.Script.Services.ScriptService]    public   class ...

Image Upload using ASP.Net with C# (Practical 8)

Default.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title> </head> <body>     <form id="form1" runat="server">     <div>             <asp:FileUpload ID="FileUpload1" runat="server" />         <br />         <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />         <br />         <br />         <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>         <br />         <br />         <asp:GridView ID="GridView1" runat="server">   ...

Practical 5 - ASP.NET

Page1.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Page1.aspx.cs" Inherits="StudentInformation.Page1" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title> </head> <body>     <form id="form1" runat="server">     <div>             <table style="width:100%;">             <tr>                 <td>Name:</td>                 <td>                     <asp:TextBox ID="txtName" runat="server"></asp:TextBox>                 </td>             </tr>             <tr>   ...

C# Code to Convert Temperature from degree Celcius to degree Fahrenheit

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Operators_A {     class Program     {         static void Main(string[] args)         {             /*              * 1. Arithmetic Operators              *  a. + (Addition)              *  b. - (Subtraction)              *  c. / (Division)              *  d. * (Multiplication)              *  e. % (Modulus, Remainder)              *  f. ++ (Increment)              *  g. -- (Decrement)              */  ...

Operator Overloading

// Operator Overloading #include <iostream> using namespace std; class Complex { private: float real; float img; public: Complex() { real = img = 0; } Complex(float real, float img) { this->real = real; this->img = img; } // Complex add(Complex c) // { // Complex tmp; // tmp.real = this->real + c.real; // tmp.img = this->img + c.img; // return tmp; // } // Opertors which cannot be oberloaded // ::, ., .*, ?: Complex operator +(Complex c) { Complex tmp; tmp.real = this->real + c.real; tmp.img = this->img + c.img; return tmp; } Complex operator -(Complex c) { Complex tmp; tmp.real = this->real - c.real; tmp.img = this->img - c.img; return tmp; } void display() { cout << this->real << " + " << this->img << "i" << endl; } }; int main() { Complex c1(10.5, 20.5), c2(9.3, 3.5), c3; // c3 = ...

Single Level Inheritance

#include <iostream> using namespace std; /*  * Types:  * 1. Single-Level Inheritance  * 2. Multi-level  * 3. Multiple  * 4. Hybrid  */ class Shape { private:   float width;   float height; public:   Shape()   {     this->width = this->height = 0.0;   }   Shape(float width, float height)   {     this->width = width;     this->height = height;   }   float get_width()   {     return this->width;   }   float get_height()   {     return this->height;   }   float getArea()   {     return this->width * this->height;   } }; class Square : public Shape { public:   Square() { }   Square(float side) : Shape(side, side)   {   }   float getPerimeter()   {     return 2 * this->get_width() + 2 * this-...

Constructors while inheritance

#include <iostream> #include <string.h> using namespace std; class A { public:   A()   {     cout << "A's constructor" << endl;   }   A(string s)   {     cout <<  "A's " << s << endl;   } }; class B : public A { public:   B()   {     cout << "B's constructor" << endl;   }   B(string s) : A(s)   {     cout << "B's " << s << endl;   } }; class C : public B { public:   C()   {     cout << "C's constructor" << endl;   }   C(string s) : B(s)   {     cout << "C's " << s << endl;   } }; int main(int argc, char const *argv[]) {   C c("Hello");   return 0; }