csharp tutorials free for beginner and expert willing to work with social networking API programming.
Introduction to Break Points
The very first thing about debugging that you need to know, is the break point. It actually does exactly what the name implies - it marks a point in your code where the execution will take a break (and no, it won't actually break your code, don't worry). Placing a breakpoints in Visual Studio or one of the Express versions, is as simple as left-clicking in the gutter, which is the grey are to the left of your code. Once you click it, you will get a shiny, red circle as a reward - this circle marks where the debugger will halt when you execute your application. You better have a look for your self, and to see the effect, we will use the following piece of code:
Now, can you predict the result just from looking at the code? Probably, and if not, you could just get out the old calculator and do the math, but that's not really the point. Just imagine the amount of code being much bigger, and let's debug the thing! Place a breakpoint by clicking in the left gutter - your IDE should now look something like this:
Okay, you're ready to start your first debugging session. As soon as you have placed the breakpoint, you can just run your application like you normally would - from the menu, the toolbar or by pressing F5. What happens now is that the application is executed just like normal, but as soon as a line with a breakpoint is reached, the execution is stopped right before that line would be executed. In this case, it means that the variables a, b and c will have a value, but d will only have it's default value (which is 0 for an integer), since it won't be set before the line with the breakpoint has been evaluated. Now, here comes the cool part - try hovering your mouse over the different variables - the IDE will tell you what they contain. As mentioned, the d variable will have it's default value, but let's change that, by moving forward in the execution. In the next chapter, I will show you how to navigate around your code, while it's being executed.
namespace DebugTest { class Program { static void Main(string[] args) { int a = 5, b = 8, c = 233; int d = a + c - b; Console.WriteLine(d); } } }
Now, can you predict the result just from looking at the code? Probably, and if not, you could just get out the old calculator and do the math, but that's not really the point. Just imagine the amount of code being much bigger, and let's debug the thing! Place a breakpoint by clicking in the left gutter - your IDE should now look something like this:
Okay, you're ready to start your first debugging session. As soon as you have placed the breakpoint, you can just run your application like you normally would - from the menu, the toolbar or by pressing F5. What happens now is that the application is executed just like normal, but as soon as a line with a breakpoint is reached, the execution is stopped right before that line would be executed. In this case, it means that the variables a, b and c will have a value, but d will only have it's default value (which is 0 for an integer), since it won't be set before the line with the breakpoint has been evaluated. Now, here comes the cool part - try hovering your mouse over the different variables - the IDE will tell you what they contain. As mentioned, the d variable will have it's default value, but let's change that, by moving forward in the execution. In the next chapter, I will show you how to navigate around your code, while it's being executed.
C sharp Tweeter api call
Features
- Drag and drop image from any where.
- Auto attach URL of your blog to your tweet image.
API Download :
Before Creating your C# app you must know to create new app in Twitter Dev. the following link Contains only API Download and its documentation Click Here
Source Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using Tweetinvi;
using Tweetinvi.Core.Interfaces;
using Tweetinvi.Core.Interfaces.Controllers;
using Tweetinvi.Core.Interfaces.DTO;
using Tweetinvi.Core.Interfaces.Factories;
using Tweetinvi.Core.Interfaces.Models;
namespace TwitterApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
protected bool validData;
string path;
protected Image image;
protected Thread getImageThread;
string AccessToken="Your_Access_token";
string TokenSecret = "Your_Token_Secret";
string ConsumerKey = "Your_Consumer_key";
string ConsumerSecret ="Your_Consumer_Secret";
private void Form1_Load(object sender, EventArgs e)
{
Tweetinvi.TwitterCredentials.SetCredentials(AccessToken,TokenSecret,ConsumerKey,ConsumerSecret);
}
private void Form1_DragDrop(object sender, DragEventArgs e)
{
if (validData)
{
while (getImageThread.IsAlive)
{
Application.DoEvents();
Thread.Sleep(0);
}
pictureBox1.Image = image;
}
}
protected void LoadImage()
{
image = new Bitmap(path);
}
private void Form1_DragEnter(object sender, DragEventArgs e)
{
string filename;
validData = GetFilename(out filename, e);
if (validData)
{
path = filename;
getImageThread = new Thread(new ThreadStart(LoadImage));
getImageThread.Start();
e.Effect = DragDropEffects.Copy;
}
else
e.Effect = DragDropEffects.None;
}
private bool GetFilename(out string filename, DragEventArgs e)
{
bool ret = false;
filename = String.Empty;
if ((e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy)
{
Array data = ((IDataObject)e.Data).GetData("FileDrop") as Array;
if (data != null)
{
if ((data.Length == 1) && (data.GetValue(0) is String))
{
filename = ((string[])data)[0];
string ext = Path.GetExtension(filename).ToLower();
if ((ext == ".jpg") || (ext == ".png") || (ext == ".bmp"))
{
ret = true;
}
}
}
}
return ret;
}
private void TweetBtn_Click(object sender, EventArgs e)
{
if (checkBox1.Checked == true && checkBox2.Checked==true)
{
string BlogUrl = "Click www.ziabse.blogspot.com For More...";
byte[] file = File.ReadAllBytes(path);
var tweet = Tweet.PublishTweetWithMedia(BlogUrl,file);
var imageURL = tweet.Entities.Medias.First().MediaType;
label1.Text = "Tweet Posted With Image :)";
}
else
if (textBox1.Text != "")
{
Tweet.PublishTweet(textBox1.Text);
label1.Text = " Tweet Posted :)";
}
else
label1.Text = "Tweet Can't Be Blank :D";
}
}
}
C sharp two combo boxes
Source Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace ComboBox
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
comboBox1.Items.Add("BATA");
comboBox1.Items.Add("SERVICE");
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
comboBox2.Items.Clear();
if (comboBox1.SelectedItem == "BATA")
{
comboBox2.Items.Add("BATA MALE SHOES");
comboBox2.Items.Add("BATA LADIES SHOES");
comboBox2.Items.Add("BATA KIDS SHOES");
}
else if (comboBox1.SelectedItem == "SERVICE")
{
comboBox2.Items.Add("SERVICE LADIES SHOES");
comboBox2.Items.Add("SERVICE MALE SHOES");
comboBox2.Items.Add("SERVICE KIDS SHOES");
}
}
}
}
c sharp Interview Questions
C# Interview Questions and Answers for freshers and experienced are below
Object-oriented programming (OOP) is a programming language model organized around objects rather than "actions" and data rather than logic. Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data.
2. Explain about C# Language.
C# is a OOPs language, .net framework use to compiled it, to generate machine code.
3. Types of comments in C#?
Single line comments
// for single line comments
Multiple line comments
/* for multi line comments */
XML tags comments
/// XML tags displayed in a code comment
4. Top reason to use C# language?
- Modern, general-purpose programming language
- Object oriented.
- Component oriented.
- Easy to learn.
- Structured language.
- It produces efficient programs.
- It can be compiled on a variety of computer platforms.
- Part of .Net Framework.
5. feature of C# language?
- Boolean Conditions
- Automatic Garbage Collection
- Standard Library
- Assembly Versioning
- Properties and Events
- Delegates and Events Management
- Easy-to-use Generics
- Indexers
- Conditional Compilation
- Simple Multithreading
- LINQ and Lambda Expressions
- Integration with Windows
6. What is a Class?
a set or category of things having some property or attribute in common and differentiated from others by kind, type, or quality.
7. What is object?
Objects are created from Classes, in C#, is an instance of a class that is created dynamically. Object is also a keyword that is an alias for the predefined type System.
8. What is Constructors, explain with syntax
A is special method of the class that will be automatically invoked when an instance of the class is created is called as constructor.
Constructors are mainly used to initialize private fields of the class while creating an instance for the class.
When you are not creating a constructor in the class, then compiler will automatically create a default constructor in the class that initializes all numeric fields in the class to zero and all string and object fields to null.
Syntax.
[Access Modifier] ClassName([Parameters])
{
}
9. Types of Constructors
- Basically constructors are 5 types those are
- Default Constructor
- Parameterized Constructor
- Copy Constructor
- Static Constructor
- Private Constructor
10. index value of the first element in an array?
first element is 0 (zero). In a Array.
11. Different between method overriding and method overloading?
In Overriding methods it will create two or more methods with same name and same parameter in different classes.
while Overloading it will create more then one method with same name but different parameter in same class.
12. Explain use of Abstract and Sealed Classes in C#?
The abstract keyword enables you to create classes and class members that are incomplete and must be implemented in a derived class.
The sealed keyword enables you to prevent the inheritance of a class or certain class members that were previously marked virtual.
13. What is Static Classes?
A static class is basically the same as a non-static class, but there is one difference: a static class cannot be instantiated.
In other words, you cannot use the new keyword to create a variable of the class type. Because there is no instance variable, you access the members of a static class by using the class name itself.
14. Explain Static Class Members.
A non-static class can contain static methods, fields, properties, or events.
The static member is callable on a class even when no instance of the class has been created. The static member is always accessed by the class name, not the instance name. Only one copy of a static member exists, regardless of how many instances of the class are created.
Static methods and properties cannot access non-static fields and events in their containing type, and they cannot access an instance variable of any object unless it is explicitly passed in a method parameter.
15. Which are Access Modifiers available in C#?
All types and type members have an accessibility level, which controls whether they can be used from other code in your assembly or other assemblies.
You can use the following access modifiers to specify the accessibility of a type or member when you declare it:
- public: The type or member can be accessed by any other code in the same assembly or another assembly that references it.
- private: The type or member can be accessed only by code in the same class or struct.protected: The type or member can be accessed only by code in the same class or struct, or in a class that is derived from that class.
- internal: The type or member can be accessed by any code in the same assembly, but not from another assembly.
bool, byte , char, decimal , double, float, int, long, sbyte , short, uint, ulong, ushort.
More question coming soon.. we are updating our list of ques and answer... :)
c sharp Linked List Implementation
SOURCE CODE
using System; using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace linklist
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
LinkedList<string> LinkedList = new LinkedList<string>();
private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
textBox1.Text = "";
foreach (var item in LinkedList)
{
listBox1.Items.Add(item);
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
string add = textBox1.Text;
if (FirstRb.Checked)
{
string find = listBox1.SelectedItem.ToString();
LinkedListNode<string> node = LinkedList.Find(find);
LinkedList.AddAfter(node, add);
}
else if(secRb.Checked)
{
string find = listBox1.SelectedItem.ToString();
LinkedListNode<string> node = LinkedList.Find(find);
LinkedList.AddBefore(node, add);
}
else
LinkedList.AddLast(textBox1.Text);
statusLabl.Text = "Status : " + textBox1.Text + " Added to List";
}
private void button3_Click(object sender, EventArgs e)
{
try
{
string RemoveItem = listBox1.SelectedItem.ToString();
// LinkedList.RemoveLast();
LinkedList.Remove(RemoveItem);
statusLabl.Text = "Status : " + RemoveItem + " Removed From List";
}
catch (Exception ) { MessageBox.Show("Please! Select A Value in List","Stop"); }
}
private void textBox1_Click(object sender, EventArgs e)
{
textBox1.Text = "";
}
}
}
Subscribe to:
Posts (Atom)
Sending SMS Via Windows Form Application Using any Android Smart Phone Source Code using System ; using System . C...
-
Using C# you can have your own Windows 7. Desktop Google Gadget. Now you can Search any web , image , Android application or even a Yo...
-
This lesson teaches C# Indexers. Our objectives are as follows: Understand What Indexers Are For. Implement an Indexer. Overload Index...
-
In this tutorial I will be showing you how you would go about controlling your system volume in C#. The reason for this tutorial is simpl...



