|
Hi
the following code use reflection in order to convert string items to value
types using the static function TryParse.
using System;
using System.Collections.Generic;
using System.Reflection;
namespace CMDLineTest
{
class Program
{
static List<t> CommaSeparatedStringToIEnumerable<t>(string s)
{
List<t> values = new List<t>();
Type targetConversionType = typeof(T);
if (targetConversionType.IsValueType)
{
Type targetConversionTypeOutParamType = Type.GetType(targetConversionType.FullName + @"&");
if(targetConversionTypeOutParamType == null)
throw new Exception("");
MethodInfo tryParseMethodInfo = targetConversionType.GetMethod("TryParse", new Type[] { typeof(string), targetConversionTypeOutParamType });
if(tryParseMethodInfo != null)
{
string[] stringsToConvert = s.Split(',');
T item = default(T);
object[] methodParams = new object[2];
foreach (string str in stringsToConvert)
{
methodParams[0] = str;
methodParams[1] = item;
if (((bool)tryParseMethodInfo.Invoke(null, methodParams)) == true)
values.Add((T)methodParams[1]);
}
}
}
return values;
}
static void Main(string[] args)
{
List<int> intList = CommaSeparatedStringToIEnumerable<int>("1,2,3,4,5");
foreach (int item in intList)
Console.WriteLine(item);
}
}
}
|
|
|
|
|
Hi Friends, can anybody suggest what are the good books for learning C#.NET. I am interested in developing WEB SERVICES in C#.NET
I have knowledge in C, C++, VC++
Suggest some good books using which I can master c#.NET
Thanks ....
poojaaa
|
|
|
|
|
Professional C# Web Services: Building .NET Web Services with ASP.NET and .NET Remoting (Paperback) by wrox publication.
by Andrew Krowczyk (Author), Zach Greenvoss (Author), Christian Nagel (Author), Ashish Banerjee (Author), Thiru Thangarathinam (Author), Aravind Corera (Author), Chris Peiris (Author), Brad Maiani (Author).
Regards,
Satips.
|
|
|
|
|
|
|
|
Does any body know how to capture audio an video form webcam and stream it direcly on to tapi Call, with out first storing it on the disk.
CallieClearence
|
|
|
|
|
hi friends..
while creating a new project in .NET 2 we have an options called Windows Apllication,Windows Control Library,class Library etc..well working on my previous project i used class library to create components in my project..
"Windows Control Library" suggests that we are going to create user controls
but we can do that thing also if we can go for class library(by right clicking class library and thn ADD-->New Item-->user Contrls)..thn whats the diff.
|
|
|
|
|
Well, there's none in reality. The only difference being what you get in the initial project, i.e. either an empty class or a barebones control class. They both compile to .DLL format.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi friends,
plz help me
i am a web developer and now i want to write a desktop application.
the dackend is "ms sql 2000" and front end is "Visual C# 2005".,but i didn\t find any control to connect to ms sql 2000
plz help
prince
|
|
|
|
|
You can use SqlConnection object to connect.
|
|
|
|
|
any control to connect.. if u can suggest me any sampple project then it will be great
prince
|
|
|
|
|
There is no control but you could do something like this:
SqlConnection cn = new SqlConnection();
cn.ConnectionString = "...";
cn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandText = "your sql sp Here";
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = ...;
SqlDataReader rdr = cmd.ExecuteReader();
You could look for samples here on codeproject.
|
|
|
|
|
If you type your question in to google, you're bound to find a ton of articles on this.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
you can use SQLDataSource control to connect with your db..
or u can use the classes to connect (through code)
u can search on google too. for this
|
|
|
|
|
Excel.Workbook theWorkbook = this.Excelobj.Workbooks.Open(strInputFileName, 0, false, 5,
"", "", true, Excel.XlPlatform.xlWindows, "\t", false, false,0, true,false,false);
Excel.Sheets sheets = theWorkbook.Worksheets;
Excel.Worksheet excelWorksheet = (Excel.Worksheet)sheets.get_Item(1);
Excel.Range tempRange = (Excel.Range) excelWorksheet.get_Range("C1","IV1");
System.Array tempArray = (System.Array)tempRange.Cells.Value2;
string[] exchangeData = ConvertToStringArray(tempArray);
//Determining the Excel Cell data range
int totalExcCount = exchangeData.Length;
string remarkCellName = convIndexToCellName(totalExcCount+3);
string lastExcCellName = convIndexToCellName(totalExcCount+2);
//Creating a new column "Remarks" in the excel.
Excel.Range remarkRange = (Excel.Range) excelWorksheet.get_Range(remarkCellName + "1",remarkCellName + "1");
string strRemark = "Remarks";
Object[] args1 = new Object[1];
args1[0] = strRemark;
remarkRange.GetType().InvokeMember("Value",BindingFlags.SetProperty,null,remarkRange,args1);
Now as above when writing in excel
I want that I should be able to write "Remarks" with some different color say red
how can i do that
Thanks
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
the get_range method itself has few poperties...
Try out the Font property and thereby you can set the color for the font!!
Gautham
|
|
|
|
|
Ankit,
Here is the Solution:
Call this line
remarkRange.Font.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red);
and this will set the Font color to RED.
Manoj
|
|
|
|
|
To fill the color for One cell,
((Excel.Range)worksheet.Cells[row, column]).Interior.Color = ColorTranslator.ToOle(color) ;
To fill the color for range.
worksheet.get_Range("A1","A2").Interior.Color = ColorTranslator.ToOle(color);
Hope to catch well!!!
|
|
|
|
|
I am using a RichTextBox on a Form. The RichTextBox shows large amount of text from the database.
The sizes of the text varies from 0 to 1500 chars.
So I start from small size RTB (400*400) and then increase the size of the RTB untill the Scroll bars are no longer shown. i.e I want to make an automatically sizing RichTextBox
I want to just check the Vertical Scrollbar, and keep increasing the height of my RichTextBox until the scrollbar is disabled/unused (this would, in theory, give it the exact height needed)
And If is increase the size of the rTB do i have to use the method
Application.DoEvents();
to show the change
o O º(`'·.,(`'·., ☆,.·''),.·'')º O o°
»·'"`»* *☆ t4ure4n ☆* *«·'"`«
°o O º(,.·''(,.·'' ☆`'·.,)`'·.,)º O o°
|
|
|
|
|
Nice signature, I guess it's one of your rtf applications
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
What is your question?
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
How Do I check that the Vertical Scroll bar is shown.
o O º(`'·.,(`'·., ☆,.·''),.·'')º O o°
»·'"`»* *☆ t4ure4n ☆* *«·'"`«
°o O º(,.·''(,.·'' ☆`'·.,)`'·.,)º O o°
|
|
|
|
|
I was using Visual studio 2003 to develop windows applications in c#. Now I have moved to Visual studio 2005. I wanted to use Datagrid in my application but the only thing I see is what is called datagridview. Are these two the same, if yea can I use the same code to populate a datagridview?
phokojoe
|
|
|
|
|