|
Thanks Colin!
Your reply is clear. Cool!
regards,
George
|
|
|
|
|
George_George wrote: I am doing input parameter checking for a string type, and string value except empty is valid. My function is provided to outer client to call. Sometimes I find to check null is not enough, I also need to check String.Empty.
Apart from your original question, you might also use String.IsNullOrEmpty[^] for this task.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks Greeeg,
Good to learn from you about the new API!
regards,
George
|
|
|
|
|
hi,
I have one table, inside this i have one server td.
Now i want to change the table cell background color dynamically i.e from the codebehind page.
If i am giving like this
First.BgColor = System.Drawing.Color.Green.ToString();
here First is my cell id.
But it is not effecting.
can anybody knows the solution, please let me know
Thanks and Regards
Dayakar D.N
|
|
|
|
|
Try another forum. This is for C#.
|
|
|
|
|
how can I get a running process start-path?
|
|
|
|
|
In the System.Diagnostics namespace, take a look at Process.MainModule.
|
|
|
|
|
What do you know about the process?
If it is the process that launched your code you can use Application.ExecutablePath
You can also use Process class.
If that doesn't help, then try this: Finding Windows Executable[^]
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Hello
I'm working on web application in VS 2005. I need to create well formatted
word document report(word file has tables).
How it should be done?
I simply dont know anything about creating and writing to word document thru c#/vb/ crystal report.
Please someone tell me how to deal with this.
TIA,
Leena
|
|
|
|
|
Hi All,
I'm trying to build some reporting into an app that I've been working on for a while.
The app has a range of class objects in memory, which I want to use to populate the report. In short, I want to push the data to the report at runtime.
I have designed the report structure (and created the .rdlc file), added a report viewer and bound the viewer to the report. However, I cannot seem to access the objects in the report for assignment.
All net searches return info on binding to database tables, but I've found nothing on binding to class objects.
Any ideas / pointers?
Thanks in advance,
John.
|
|
|
|
|
Open the .rdlc file and you should now have a Data menu item in the VS menu. Click Add New Data Source, select Object and go through the wizard.
Scott P
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra
|
|
|
|
|
Hi Scott,
I can do that, but once a class is in my data sources tab, I can't look at the componants and can't attach them to a part of my report.
In addition, a lot of the data items I have are time-series items. I will want to set a date for the report and include only data items up to that date. Is there a way to create a dataset in code and dynamically attach it to the report?
Thanks,
John.
|
|
|
|
|
If you have your report active in a tab, you should have a Report menu item. You have to use that to add sources to the particular report. Then you should have them as choices when you put components down on the report. If you didn't know already, you have to pass data in as a generic list even if there's only one object that you're working with. And be warned that the editor is NOT NICE when it comes to revising the report, I can't tell you how many times I've had to manually edit the rdlc file to fix something that the automation broke.
Scott P
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra
|
|
|
|
|
Hi,
I've got this piece of code:
Assembly asm = Assembly.LoadFrom(@"C:\Documents and Settings\someDll.dll");
Type type = asm.GetType(someClass);
How can I instantiate a list for the type found above? something like (doesn't work):
System.Collections.Generic.IList<type> list = new System.Collections.Generic.List<type>();
Thanks in advance
|
|
|
|
|
Member 3754905 wrote: How can I instantiate a list for the type found above? something like (doesn't work):
I am not sure I got your question, are you looking to instantiate the type ? Try Activator.CreateInstance()
|
|
|
|
|
No, I've got the type.
I want to make a generic list that contains objects of the type I just found. E.g.:
List<typefound> list = new List<typefound>();
|
|
|
|
|
If the generic type has a default constructor (zero-arg), then all you need do is add a constraint to handle it. Consider this example:
public class CreatableTest<T> where T : new()
{
public static T CreateTestObject()
{
return new T();
}
} The section where T : new() adds the ability to call the default constructor.
|
|
|
|
|
That wont work The type is not known at compile time.
|
|
|
|
|
leppie wrote: That wont work The type is not known at compile time.
Sorry, but it is. Try this sample:
using System;
using System.Collections.Generic;
using System.Text;
namespace MyClass
{
public class Class1
{
public static T Create<T>() where T : new()
{
return new T();
}
}
public class MyTest
{
public MyTest()
{
}
}
} This can be called by:
using System;
using System.Collections.Generic;
using System.Text;
namespace TestHandler
{
class Program
{
static void Main(string[] args)
{
MyClass.MyTest test = MyClass.Class1.Create<MyClass.MyTest>();
if (test != null)
Console.WriteLine("Here I am");
Console.ReadLine();
}
}
} Works fine - it's not useful because other constraints would be useful such as constraining it to a type to get default information.
|
|
|
|
|
Like I said, the type is NOT known at compile time, hence your second snippet will not compile
|
|
|
|
|
Strange - it compiled AND ran when I did it.
|
|
|
|
|
Your code as it is will compile. But in the OP's case, he has no type there yet, so it wont work (you cant just make one there!).
So to wrap it up:
- he loads an assembly
- he gets a type (one that is not known when he compiled the code)
- make a generic List of the runtime type via Type.MakeGenericType, as the type is not known at compile time
|
|
|
|
|
leppie wrote: But in the OP's case, he has no type there yet
Which is why I mentioned that additional constraints would be needed. For instance, he could use IList as a constraint to identify that the item is a list of type T.
|
|
|
|
|
The OP is trying to instantiate a generic class, with only the Type instance for the actual type available. In your example, you were able to pass MyClass as a type parameter, the OP has only typeof(MyClass), which he got through reflection.
|
|
|
|
|
Well spotted - I missed that. That'll teach me not to skim read the question.
|
|
|
|