package com.example.helloandroid;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloAndroid extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
}
}
All the question that scared me now i am trying to scare them .. so that they cant scare others :)
Wednesday, June 29, 2011
Android Hello World Program
C++ Design Pattern
- Creational Patterns: deal with initializing and configuring classes and objects
- Structural Patterns: deal with decoupling the interface and implementation of classes and objects
- Behavioral Patterns: deal with dynamic interactions among societies of classes and objects
SmtpMail and Mail Message
using System.Web.Util
sendmail()
{
MailMessage mailMsg = new MailMessage();
mailMsg .From = "from@fromServer.com";
mailMsg .To = "to@toServer.com";
mailMsg .Cc = "cc@ccServer.com"";
mailMsg .Bcc = "bcc@bccServer.com";
mailMsg .Subject = "SubjectOfTheMailString";
mailMsg .Body = "BodyOfTheMailString";
SmtpMail.Send(mailMsg );
}
sendmail()
{
MailMessage mailMsg = new MailMessage();
mailMsg .From = "from@fromServer.com";
mailMsg .To = "to@toServer.com";
mailMsg .Cc = "cc@ccServer.com"";
mailMsg .Bcc = "bcc@bccServer.com";
mailMsg .Subject = "SubjectOfTheMailString";
mailMsg .Body = "BodyOfTheMailString";
SmtpMail.Send(mailMsg );
}
How to send e-mail programmatically by using System.Web.Mail in Visual C#
using System;
using System.Web.Mail;
namespace WebMail
{
class Class1
{
static void Main(string[] args)
{
try
{
MailMessage oMsg = new MailMessage();
oMsg.From = "sender@somewhere.com";
oMsg.To = "recipient@somewhere.com";
oMsg.Subject = "Send Using Web Mail";
oMsg.BodyFormat = MailFormat.Html;
oMsg.Body = "<HTML><BODY><B>Hello World!</B></BODY></HTML>";
String sFile = @"C:\temp\Hello.txt";
MailAttachment oAttch = new MailAttachment(sFile, MailEncoding.Base64);
oMsg.Attachments.Add(oAttch);
SmtpMail.SmtpServer = "MySMTPServer";
SmtpMail.Send(oMsg);
oMsg = null;
oAttch = null;
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
}
}
}
}
Add a reference to the System.Web.dll namespace
Color Codes Hexadecimal..
| 000 | 300 | 600 | 900 | C00 | F00 |
| 003 | 303 | 603 | 903 | C03 | F03 |
| 006 | 306 | 606 | 906 | C06 | F06 |
| 009 | 309 | 609 | 909 | C09 | F09 |
| 00C | 30C | 60C | 90C | C0C | F0C |
| 00F | 30F | 60F | 90F | C0F | F0F |
| 030 | 330 | 630 | 930 | C30 | F30 |
| 033 | 333 | 633 | 933 | C33 | F33 |
| 036 | 336 | 636 | 936 | C36 | F36 |
| 039 | 339 | 639 | 939 | C39 | F39 |
| 03C | 33C | 63C | 93C | C3C | F3C |
| 03F | 33F | 63F | 93F | C3F | F3F |
| 060 | 360 | 660 | 960 | C60 | F60 |
| 063 | 363 | 663 | 963 | C63 | F63 |
| 066 | 366 | 666 | 966 | C66 | F66 |
| 069 | 369 | 669 | 969 | C69 | F69 |
| 06C | 36C | 66C | 96C | C6C | F6C |
| 06F | 36F | 66F | 96F | C6F | F6F |
| 090 | 390 | 690 | 990 | C90 | F90 |
| 093 | 393 | 693 | 993 | C93 | F93 |
| 096 | 396 | 696 | 996 | C96 | F96 |
| 099 | 399 | 699 | 999 | C99 | F99 |
| 09C | 39C | 69C | 99C | C9C | F9C |
| 09F | 39F | 69F | 99F | C9F | F9F |
| 0C0 | 3C0 | 6C0 | 9C0 | CC0 | FC0 |
| 0C3 | 3C3 | 6C3 | 9C3 | CC3 | FC3 |
| 0C6 | 3C6 | 6C6 | 9C6 | CC6 | FC6 |
| 0C9 | 3C9 | 6C9 | 9C9 | CC9 | FC9 |
| 0CC | 3CC | 6CC | 9CC | CCC | FCC |
| 0CF | 3CF | 6CF | 9CF | CCF | FCF |
| 0F0 | 3F0 | 6F0 | 9F0 | CF0 | FF0 |
| 0F3 | 3F3 | 6F3 | 9F3 | CF3 | FF3 |
| 0F6 | 3F6 | 6F6 | 9F6 | CF6 | FF6 |
| 0F9 | 3F9 | 6F9 | 9F9 | CF9 | FF9 |
| 0FC | 3FC | 6FC | 9FC | CFC | FFC |
| 0FF | 3FF | 6FF | 9FF | CFF | FFF |
Design Patterns in .net
| Behavioral Patterns | |
| Chain of Resp. | A way of passing a request between a chain of objects |
| Command | Encapsulate a command request as an object |
| Interpreter | A way to include language elements in a program |
| Iterator | Sequentially access the elements of a collection |
| Mediator | Defines simplified communication between classes |
| Memento | Capture and restore an object's internal state |
| Observer | A way of notifying change to a number of classes |
| State | Alter an object's behavior when its state changes |
| Strategy | Encapsulates an algorithm inside a class |
| Template Method | Defer the exact steps of an algorithm to a subclass |
| Visitor | Defines a new operation to a class without change |
| Structural Patterns | |
| Adapter | Match interfaces of different classes |
| Bridge | Separates an object’s interface from its implementation |
| Composite | A tree structure of simple and composite objects |
| Decorator | Add responsibilities to objects dynamically |
| Facade | A single class that represents an entire subsystem |
| Flyweight | A fine-grained instance used for efficient sharing |
| Proxy | An object representing another object |
| Creational Patterns | |
| Abstract Factory | Creates an instance of several families of classes |
| Builder | Separates object construction from its representation |
| Factory Method | Creates an instance of several derived classes |
| Prototype | A fully initialized instance to be copied or cloned |
| Singleton | A class of which only a single instance can exist |
Official Google Blog: Introducing the Google+ project: Real-life sharing...
Official Google Blog: Introducing the Google+ project: Real-life sharing...: "Update : For our international readers, this post is also available in French , German , Italian , Japanese , Portuguese , Russian and Span..."
Singleton Class in C++
class SingletonClass
{
private:
static bool SingletonIsstanceFlag;
static SingletonClass *single;
SingletonClass()
{
//private constructor
}
public:
static SingletonClass* getInstance();
void method();
~SingletonClass()
{
SingletonIsstanceFlag = false;
}
};
{
private:
static bool SingletonIsstanceFlag;
static SingletonClass *single;
SingletonClass()
{
//private constructor
}
public:
static SingletonClass* getInstance();
void method();
~SingletonClass()
{
SingletonIsstanceFlag = false;
}
};
Singleton Pattern & its implementation with C++
#include
#include "Singleton.h"
using namespace std;
void useSingleton(){
Singleton* singletoneg= Singleton::getInstance();
singleton->doSummut();
// this shouldn't be allowed
Singleton* doubleton;
doubleton->doSummutElse();
}
int main(int argc, char** argv) {
useSingleton();
return (EXIT_SUCCESS);
}
#include "Singleton.h"
using namespace std;
void useSingleton(){
Singleton* singletoneg= Singleton::getInstance();
singleton->doSummut();
// this shouldn't be allowed
Singleton* doubleton;
doubleton->doSummutElse();
}
int main(int argc, char** argv) {
useSingleton();
return (EXIT_SUCCESS);
}
Tuesday, June 28, 2011
Delegates (C# Programming)
Delegates have the following properties:
- Delegates are like C++ function pointers but are type safe.
- Delegates allow methods to be passed as parameters.
- Delegates can be used to define callback methods.
- Delegates can be chained together; for example, multiple methods can be called on a single event.
- Methods do not have to match the delegate signature exactly. For more information, see Using Variance in Delegates (C# and Visual Basic).
- C# version 2.0 introduced the concept of Anonymous Methods, which allow code blocks to be passed as parameters in place of a separately defined method. C# 3.0 introduced lambda expressions as a more concise way of writing inline code blocks. Both anonymous methods and lambda expressions (in certain contexts) are compiled to delegate types. Together, these features are now known as anonymous functions. For more information about lambda expressions, see Anonymous Functions (C# Programming Guide).
public delegate int PerformCalculation(int x, int y);
A delegate is a type that defines a method signature. When you instantiate a delegate, you can associate its instance with any method with a compatible signature. You can invoke (or call) the method through the delegate instance.
Delegates are used to pass methods as arguments to other methods. Event handlers are nothing more than methods that are invoked through delegates. You create a custom method, and a class such as a windows control can call your method when a certain event occurs delegate void Delegate1(); delegate void Delegate2(); static void method(Delegate1 d, Delegate2 e, System.Delegate f) { // Compile-time error. //Console.WriteLine(d == e); // OK at compile-time. False if the run-time type of f // is not the same as that of d. System.Console.WriteLine(d == f); }
Interfaces (C# Programming)
Interfaces consist of methods, properties, events, indexers, or any combination of those four member types. An interface cannot contain constants, fields, operators, instance constructors, destructors, or types. It cannot contain static members. Interfaces members are automatically public, and they cannot include any access modifiers.
When a class or struct implements an interface, the class or struct provides an implementation for all of the members defined by the interface. The interface itself provides no functionality that a class or struct can inherit in the way that base class functionality can be inherited. However, if a base class implements an interface, the derived class inherits that implementation. The derived class is said to implement the interface implicitly.
Classes and structs implement interfaces in a manner similar to how classes inherit a base class or struct, with two exceptions:
When a class or struct implements an interface, the class or struct provides an implementation for all of the members defined by the interface. The interface itself provides no functionality that a class or struct can inherit in the way that base class functionality can be inherited. However, if a base class implements an interface, the derived class inherits that implementation. The derived class is said to implement the interface implicitly.
Classes and structs implement interfaces in a manner similar to how classes inherit a base class or struct, with two exceptions:
- A class or struct can implement more than one interface.
- When a class or struct implements an interface, it receives only the method names and signatures, because the interface itself contains no implementations
public class Car : IEquatable<Car> { public string Make {get; set;} public string Model { get; set; } public string Year { get; set; } // Implementation of IEquatable<T> interface public bool Equals(Car car) { if (this.Make == car.Make && this.Model == car.Model && this.Year == car.Year) { return true; } else return false; } }
An interface has the following properties:
- An interface is like an abstract base class: any non-abstract type that implements the interface must implement all its members.
- An interface cannot be instantiated directly.
- Interfaces can contain events, indexers, methods, and properties.
- Interfaces contain no implementation of methods.
- Classes and structs can implement more than one interface.
- An interface itself can inherit from multiple interfaces.
Subscribe to:
Posts (Atom)
Featured Posts
How to Enable and Configure Remote Desktop (RDP) on Ubuntu 24.04.4 LTS
Remote Desktop Protocol (RDP) support in Ubuntu has become considerably easier with the GNOME Remote Desktop stack included in modern Ubuntu...
-
public struct CoOrds { public int x, y; public CoOrds( int p1, int p2) { x = p1; y = p2; } }
-
LM Studio Overview LM Studio is a desktop application designed for developing and experimenting with large language models (LLMs)...