|
Are you aware that the .NET C# Math library includes a 'Pow function: [^]. Note that this function takes Type 'double arguments, and returns a Type 'double result.
Tutorial on Math.Pow here: [^].
Note that my posting this does not mean that I think the OP working this out for themselves is not a good thing
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
This function calculate nth power of a number (where n is the input given by user), if user has not given any input to application, it default collect it as 2 and calculate its 2nd power.
To calculate power system has multiply same number with itself upto nth time and get the desired value
Find More .Net development tips at : .NET Tips
The only reason people get lost in thought is because it's unfamiliar territory.
|
|
|
|
|
I was trying to load a type using only the type FullName and the Assembly name (unqualified, no version number or hash signature)
It seemed to work for some types....
But some .NET dll does not work, for example:
Type.GetType("System.Drawing.Bitmap,System.Drawing")
returns null (even though my app is currently displaying some WinForm Forms).
Any clue ho how to fix that?
I am also hampering myself by trying to write code that will work on Android, .NET Core, UWP....
[EDIT]
AppDomain.Current.GetAssemblies() works on iOS, Android, .NET desktop!
And .NET Core has something similar..
problem solved!
modified 2-Jul-16 8:21am.
|
|
|
|
|
An overloaded version of the same method allows you to throw an exception if there's an error. It would throw a TypeLoadException[^].
On my machine it is complaining that there is no such type in "ConsoleApplication14". Which is not exactly what I expected
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
My first thought would be that the current Project does not have a valid reference to System.Drawing, but, I am not familiar with the context (UWP ?) you are working with here.
cheers, Bill
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
Hi Bill,
After some testing I gave up on UWP!
This is for the serializer and UWP stream would have been incompatible with the desktop due to the lack of TypeConverter and ISerializable. Even more vexing I can't find the list of loaded assemblies!
So my serializer target is only desktop .NET, iOS, Android and (coming when VS support .NET Core properly) .NET Core.
As a side note, yes it fails, in a windows forms project...
(it being Type.GetType("System.Drawing.Size,System.Drawing") returns null)
Although, FYI, it succeeed if I use the assembly fullname (with version and evidence) which I don't want to...
So for now I just do the code below now, it works!
public static Type GetType(string typeName, string assemblyName)
{
Type result;
var tass = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(x => x.GetName().Name == assemblyName);
if (tass != null)
return tass.GetType(typeName);
return null;
}
BTW, did you get the link I send you!?
There is a live version of the serializer now!
(F5 on test project duplicate a winform)
GitHub - superlloyd/Galador.Reflection[^]
|
|
|
|
|
Hello
I have Excel work book with many Rows, how I can split each bunch of rows to a Sheet, by using some of the speedy stuff you guys have.
Please help or I will lose my job.
|
|
|
|
|
Let me think about that ....
(Dump as CSV, split into multiple files, reload, ...)
|
|
|
|
|
You could do it by writing a short Excel macro, something along the lines of:
Sub Macro1()
Rows("1:12").Select
Selection.Cut
Sheets.Add After:=Sheets(Sheets.Count)
Selection.Insert Shift:=xlDown
End Sub
|
|
|
|
|
By itself, Excel comes with a language Visual Basic , you can write your own programs called macros .
You can even record macros as you use Excel, the recorded macro is a Visual Basic program.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
public class AMCOMDB : DataContext
{
public Table<student> allStudents;
public Table<aClass> allClasses;
public AMCOMDB(string connection) : base(connection) { }
}
[Table(Name = "student")]
public class student
{
private string _studentName;
[Column(IsPrimaryKey =true,Storage ="_studentName")]
public string studentName
{
get
{
return this._studentName;
}
set
{
this._studentName = value;
}
}
private string _LARType;
[Column(Storage ="_LARType")]
public string LARType
{
get
{
return this._LARType;
}
set
{
this._LARType = value;
}
}
private string _studentType;
[Column(Storage = "_studentType")]
public string studentType
{
get
{
return this._studentType;
}
set
{
this._studentType = value;
}
}
private string _aviationLevel;
[Column(Storage = "_aviationLevel")]
public string aviationLevel
{
get
{
return this._aviationLevel;
}
set
{
this._aviationLevel = value;
}
}
private string _airDefenseLevel;
[Column(Storage = "_airDefenseLevel")]
public string airDefenseLevel
{
get
{
return this._airDefenseLevel;
}
set
{
this._airDefenseLevel = value;
}
}
private string _emergencyContact;
[Column(Storage = "_emergencyContact")]
public string emergencyContact
{
get
{
return this._emergencyContact;
}
set
{
this._emergencyContact = value;
}
}
[Table(Name = "grades")]
public class grades
{
private string _studentName;
[Column(IsPrimaryKey = true, Storage = "_studentName")]
public string studentName
{
get
{
return this._studentName;
}
set
{
this._studentName = value;
}
}
private int _ET;
[Column(Storage = "_ET")]
public int ET
{
get
{
return this._ET;
}
set
{
this._ET = value;
}
}
private int _CP;
[Column(Storage = "_CP")]
public int CP
{
get
{
return this._CP;
}
set
{
this._CP = value;
}
}
private int _SB;
[Column(Storage = "_SB")]
public int SB
{
get
{
return this._SB;
}
set
{
this._SB = value;
}
}
private int _EC;
[Column(Storage = "_EC")]
public int EC
{
get
{
return this._EC;
}
set
{
this._EC = value;
}
}
private int _finalGrade;
[Column(Storage = "_finalGrade")]
public int finalGrade
{
get
{
return this._finalGrade;
}
set
{
this._finalGrade = value;
}
}
[Table(Name = "classes")]
public class aClass
{
private string _classNumber;
[Column(IsPrimaryKey = true, Storage = "_classNumber")]
public string classNumber
{
get
{
return this._classNumber;
}
set
{
this._classNumber = value;
}
}
private string _courseSeries;
[Column(Storage = "_courseSeries")]
public string courseSeries
{
get
{
return this._courseSeries;
}
set
{
this._courseSeries = value;
}
}
private string _courseNumber;
[Column(Storage = "_courseNumber")]
public string courseNumber
{
get
{
return this._courseNumber;
}
set
{
this._courseNumber = value;
}
}
private string _distanceLearning;
[Column(Storage = "_distanceLearning")]
public string distanceLearning
{
get
{
return this._distanceLearning;
}
set
{
this._distanceLearning = value;
}
}
private string _classStartDate;
[Column(Storage = "_classStartDate")]
public string classStartDate
{
get
{
return this._classStartDate;
}
set
{
this._classStartDate = value;
}
}
private string _classEndDate;
[Column(Storage = "_classEndDate")]
public string classEndDate
{
get
{
return this._classEndDate;
}
set
{
this._classEndDate = value;
}
}
private string _primaryInstructor;
[Column(Storage = "_primaryInstructor")]
public string primaryInstructor
{
get
{
return this._primaryInstructor;
}
set
{
this._primaryInstructor = value;
}
}
private string _secondaryInstructor;
[Column(Storage = "_secondaryInstructor")]
public string secondaryInstructor
{
get
{
return this._secondaryInstructor;
}
set
{
this._secondaryInstructor = value;
}
}
private string _location;
[Column(Storage = "_location")]
public string location
{
get
{
return this._location;
}
set
{
this._location = value;
}
}
private string _TDYCosts;
[Column(Storage = "_TDYCosts")]
public string TDYCosts
{
get
{
return this._TDYCosts;
}
set
{
this._TDYCosts = value;
}
}
private string _studentCount;
[Column(Storage = "_studentCount")]
public string studentCount
{
get
{
return this._studentCount;
}
set
{
this._studentCount = value;
}
}
private List<grades> _classGrades;
[Column(Storage = "_classGrades")]
public List<grades> classGrades
{
get
{
return this._classGrades;
}
set
{
this._classGrades = value;
}
}
As you can see I have 3 classes under 1 database file. The problem I am having is that when I try to pull data using:
AMCOMDB ADB = new AMCOMDB(connectionString);
if (ADB.DatabaseExists())
{
var stud = ADB.GetTable<student>();
var clas = ADB.GetTable<aClass>();
IQueryable<string> query = from c in stud
where c.studentName.Length > 5
orderby c.studentName.Length
select c.studentName.ToUpper();
foreach (string name in query)
{
}
}
I get this at the foreach statement:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: Invalid object name 'student'.
I have tried to change everything and I even tried to create 3 database files but the error still comes up. I don't know what I am doing wrong. Any help is appreciated.
modified 1-Jul-16 15:28pm.
|
|
|
|
|
The results of the query can be "null"; you need to check your "query" variable for null (and also pick a more descriptive / less confusing variable name).
|
|
|
|
|
Hi, I'm using a property as byte array in a model. Now while serializing this model into xml, if this property is null, then it's not rendering as tag. I'm using [XmlElement(IsNullable=true)] attribute on that property.If i do this, in this case it's creating tag with attribute something like xi:nil=true. I don't want this. If that property is null, then make it as empty element else assign value.
Please give me solution.
|
|
|
|
|
Why do you care what the XML looks like?
Supply a default constructor for the class in question with an initializer for the byte array to resolve any nulls when de-serializing.
|
|
|
|
|
The other party app receiving XML without any attributes. If any attributes are there that throwing exception
|
|
|
|
|
Then use the error handler of the serializer to do a fix-up.
Or tell the receiving app to fix their class constructor.
You don't like your options? Life is hard and you die.
|
|
|
|
|
Hi all,
I am trying to make a program that locks the computer every 1 hour, and display a window to the user, this should have a question , and textbox to answer the question.
I don't how to do this exactly, i tried to make a code to change the password of the user to be the answer of some question and the password hint to be the question, but i failed.
I don't know if this method works or not, if you can help me to do this, then i am grateful
However, if you know any other techniques to do this, please suggest
|
|
|
|
|
You're trying to do what?!??? Seriously, why are you trying to do this?
This space for rent
|
|
|
|
|
I think you know the answer to your question.
|
|
|
|
|
It has to be asked. There's a one in 10 billion chance it might be legit.
This space for rent
|
|
|
|
|
Yep, and the population of the planet is somewhat less than ten billion....
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
|
Was your hour up when you were writing that post?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
You create your own desktop[^], and set it to the foreground. Next you run your GUI in that Desktop, and close the desktop again if the requirements are met.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|