|
Hi!
How can I find e.g. the 4th root of a number in c#?? are there any functions or should I write a function by myself??
mfg
harrior
|
|
|
|
|
Math.Pow(x,y)
To get a square root, y=0.5
To get a cubed root, y=0.33333
To get a 4th root, y=0.25
...and so on.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
Thx! Why didn't I think about fractions as exponents... *grml*
|
|
|
|
|
I have written a custom control which has its default constructor set as Private, to force the use of one of the other contsructors with args. This all works fine until you visit the GUI designer and then the code in the private void InitializeComponent() is replaced with code to instantiate my control object using the default constructor i.e. no args. How can I stop the GUI designer from overwriting the code line already enterred?
|
|
|
|
|
Read Enhancing Design-Time Support[^] about how to use UITypeEditor s, TypeConverter s, and more (like the CodeDomSerializer ) to enhance the design-time control over your component.
IIRC, however, the designer requires a default constructor becuase it handles instantiation of certain controls (i.e., the ones you dropped onto the surface). Those controls can further use the CodeDomSerializer (see the DesignerSerializerAttribute documentation) to serialize code that they use (like style objects)) and control how they interact with the designer, but the default constructor is serialized by the designer (ex: Visual Studio) itself.
Consider another approach, however. The designer supports the ISupportInitialize interface. Implement that interface on your component. By the time EndInit is called, a property (that you're currently implementing through a constructor parameter) better be set or you throw the appropriate exception. That's actually a more common approach (but you can implement and use the ISupportInitialize for other purposes as well).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi Sameer,
There is rowchange event which fires when ever a row changes. Probably you can try that.
regards
Jo
|
|
|
|
|
Hi,
I'm trying to provide the user of my class access to the objects in a collection without allowing him to modify (add/remove/clear items) the collection. I thought I can do it by providing a IEnumerator. But this thingy can't be used directly, as shown in the code below. How can this be done?
Thanks in advance.
Matthias
Here the test I tried:
using System;
using System.Collections;
using System.Collections;
public class MyClass
{
public static void Main()
{
string s1 = "Hello";
string s2 = "World!";
a.Add(s1);
a.Add(s2);
foreach (String s in GetEnumerator())
Console.WriteLine(s);
}
private static IEnumerator GetEnumerator() {
return a.GetEnumerator();
}
private static ArrayList a = new ArrayList();
}
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
www.emvoid.de
|
|
|
|
|
hi,
Your idea is good but your code block is not enough to support your requirement.
This IEnumerable interface have only one abstract method called GetEnumerator. This GetEnumerator will return an interface called IEnumerator. This IEnumerator interface containe two abstract methods and a property. MoveNext(),Reset() and a property called Current.
To achive your need you can define the methods and property like below.
public void Reset()
{
}
public bool MoveNext()
{
}
public object Current
{
get
{
}
}
This is the basic idea.
What you are doing is not sufficient to achive that. That's why you are getting an error message like.
"foreach statement cannot operate on variables of type 'System.Collections.IEnumerator' because 'System.Collections.IEnumerator' does not contain a definition for 'GetEnumerator', or it is inaccessible
"
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Ok, in a DS i have a ID coulmn which is set to autoincrement. I do something like this
this._dsSomething.Tables["something"].Rows.Add( ItemArray );
Well this causes the autoincrement column to increment to something. Well I need to access that row bases oin this id index. So, how do i access the autoIncrementCurrent property of this column. Or better yet is there a easy simple way of accessing the current row the datatable is working with.
Sameer
|
|
|
|
|
Hi all,
I created a custom user contols which accepts some parameters and fetches records to a datagrid and display it.
The problem is:
Now i need to pass a dynamic variable say I need to pass it like this;
<dgf:ucontrol param1="<%=qryData%>" param2="Hello">
But this doesn't work and it says invalid syntax near "<".
Please help
Thanks in advance,
|
|
|
|
|
This really belongs in the ASP.NET forum, but more than likely you need to escape < with <.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I need some help with updating bookmarks in a Word 2002 document using a C# app. I'm new to all of this so if I haven't provided you enough info just let me know.
private void BookMarkReplaceRange(string bookmarkName, string newText)
{
object missingValue = Type.Missing;
object oBookmarkName = bookmarkName;
Word.Range rng = oDoc.Bookmarks.get_Item (refBookmarkName).Range;
rng.Text = newText;
object oRng = rng;
oDoc.Bookmarks.Add(bookmarkName, ref oRng);
}
//calling it with:
BookMarkReplaceRange("ptname","txtLName");
The code builds fine and when I run it it will run fine until it starts running the range code. When the document is displayed it has "bookmark not defined" in place of where the bookmark text should be. I'm getting an error at
Word.Range rng = oDoc.Bookmarks.get_Item(refoBookmarkName).Range;
object reference not set to an instance of object.
|
|
|
|
|
Hi!
There are two possibilities for the "object reference..." error:
Either you didn't assign anything to oDoc or the bookmark doesn't exist and thus cannot have a Range property (get_Item returned null).
Check both possibilities and you should be fine.
Regards,
mav
|
|
|
|
|
Thanks Mav
I didn't assign anything to oDoc. I'm new to programming so I'm still learning what the heck classes, objects, methods etc are. I guess the more I do, the more I'll learn.
Chad
|
|
|
|
|
i want use mask to transparence ,how can i do?
|
|
|
|
|
Just set the transparent colour in an ImageAttributes object and use the DrawImage methods that take it.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
can you give me a sample?
i really need it,
thanks!
|
|
|
|
|
I'm looking for a WinForm control that emulates the look of the Month view of Outlook 2002.
I figure most of the grid controls out there will be able to do this. I'm looking for a control that scrolls and redraws reasonably fast. Each day of the view will contain at least three coloured sections ("appointments") - which must be dragable.
I've been looking at the various controls sold by Infragistics, ComponentOne and the like. They all seem like okay packages, so I'd like recommendations from existing users to which one they think is best.
Michael
CP Blog [^]
|
|
|
|
|
Hello all,
I wana ask a simple question!
How a Stream object can be saved into the disk?!!
Thank u
---
"Art happens when you least expect it."
|
|
|
|
|
Hi,
Stream is an abstract base class. You could use it's deriative, the FileStream for easy writing to a file using the BinaryFormatter class.
HTH,
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
www.emvoid.de
|
|
|
|
|
It greatly depends on what the stream is. More information would be helpful.
The snippet below - depending on whether or not the stream supports seeking - would work for many cases (but certainly not all, like with a NetworkStream - but not limited to it):
if (stream.CanSeek<)
{
stream.Seek(0, SeekOrigin.Begin);
using (FileStream file = new FileStream("file.dat", FileMode.Create,
FileAccess.Write, FileShare.Read))
{
int read = 0;
byte[] buffer = new byte[4096];
while ((read = stream.Read(buffer, 0, 4096)) > 0)
{
file.Write(buffer, 0, read);
}
file.Flush();
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I want to take a file as input and using PKZip or Win Zip extract it..All through C# code.
How to go about it??
|
|
|
|
|
|
Many Thanx....for solution.
|
|
|
|
|