|
Just look at what you are doing with the Body property of the messages. You set them, then give contents, and then overwrite the contents again.
And actually I expect a runtime error at
Attachment att = ...
MyMessage.Body = "<HTML><BODY BGCOLOR=#0000FF>"+att+"
|
|
|
|
|
Hi all,
I would like to write a function of type Bool that checks an array for a certain value or a function of type Void to simply sort an array. If I write a function for only a particular array type, the function is pretty straight forward but inflexible. However, if I want the function to work on any kind of array regardless of it's type, it is pretty tricky. I have tried to do this by using a For Loop in the function. Then I tried to pass in the name of the array and it's length as parameters but got stuck. The problem is if I pass in the name of an array as a parameter, that parameter must have a type. Then I tried to use the ForEach Loop where I can enter the array name but it seems it also needs to know what array type it is dealing with. The following are what I have tried:
public bool myFunction(ARRAYTYPE myArrayName, int myArrayLength)
{
for(int i = 0; i<myArrayLength;i++)
{
}
}
public void myFunction(ARRAYTYPE myArrayName )
{
foreach (ARRAYTYPE value in myArrayName)
{
}
}
I'm beginning to think this can't be done but I'm really hoping someone has a solution. Thanks in advance for your reply.
modified 16-Oct-12 8:42am.
|
|
|
|
|
The examples you post aren't really suitable for handling in a single method because the internal implementations are too different. In other words, they don't have common behaviour, so you shouldn't try to treat them as though they do.
On a general note, you can use generics to pass in a type to a method when you want to be able to use different types, decided at compile time. To do this, you would declare it like this (changing the array to a generic list instead):
public void MyFunction<T>(List<T> myCollection){
}
|
|
|
|
|
Note that you can also do this with arrays:
public void MyFunction<T>(T[] myArray){
}
Dave Doknjas
Convert between VB, C#, C++, & Java
www.tangiblesoftwaresolutions.com
Instant C# - VB to C# Converter
Instant VB - C# to VB Converter
|
|
|
|
|
ASPnoob wrote: I would like to write a function of type Bool that checks an array for a certain value or a function of type Void to simply sort an array
Try the recommended approach; IComparable[^].
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
how to get an data from sql in data gride view want all detail about data grid view
|
|
|
|
|
|
|
I have a class
class Commentable
{
public void Addcomment()
}
public Interface ICommentable
{
Commentable Comment{ get; }
}
public Class Article:Someclass,ICommentable
{
#region ICommentable Members
public Commentable Comment{
{
get { return new Commentable(); }
}
#endregion
}
public class Program
{
static void Main()
{
Article objArticle = new Article();
objArticle.comment.AddComment();
}
}
Instead of " objArticle.comment.AddComment();" in main method I want objArticle.AddComment().How do I do that without implementing the AddComment() method in Article.?
|
|
|
|
|
If you want direct access to the child of a child class and you don't want to reimplement AddComment , you either have to have that indirection in there, or you make Article derive from Commentable . There is no other way.
|
|
|
|
|
Using an extension method[^]. It's fugly BTW, it'd be a lot cleaner to simply talk to the object that you're actually using, as opposed to hiding implementation-details. Makes debugging (and thus, maintenance) a whole lot worse.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Hmmm, an interesting suggestion, but ultimately, it boils down to roughly the same IL - and it would require a reimplementation of the offending AddComment method (even if he just chooses to use a different name).
|
|
|
|
|
Pete O'Hanlon wrote: it boils down to roughly the same IL
..but not the same source-code. Hiding the member in a different (static) class does not improve readability much.
Applying Demeters' law would be costly.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Thank u so much for the suggestion it really helped me a lot
|
|
|
|
|
Hi,
I want to develop an windows desktop application to play videos from memory stream.i'm downloading video files from internet and put in to byte stream array in memory. it is working and i dont want to save them in hard disk.i want to play that video streams from memory.I'm using c# (VS2010).
I'm highly appreciate your advice and time.
Thanks
|
|
|
|
|
SumithF wrote: it is working
SumithF wrote: i dont want to save them in hard disk.i want to play that video streams from
memory
Well, I have no idea what your code looks like, so I'm going to have to guess here, but what are the overloads available for playing the video stream? I suspect that at least one of them will accept a Stream object - all you need do is pass in a MemoryStream and it will behave as you want.
|
|
|
|
|
SumithF wrote: I'm highly appreciate your advice and time.
That explains the downvote on the first post.
SumithF wrote: I want to develop an windows desktop application to play videos from memory stream.i'm downloading video files from internet and put in to byte stream array in memory. it is working and i dont want to save them in hard disk.i want to play that video streams from memory.I'm using c# (VS2010).
..and your question is this; you have the data in-memory in a stream, now how do you get it in the Media Player? Is that correct? ..and you're looking for a "tutorial" or a code-sample that you can copy?
I'm not writing code today, so you'd have to do that yourself. The documentation is here[^], complete with an example. Give it a try.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
I am updating an old project developed with VS2008, and as part of the deployment it needs to create a directory in the root of C: and a number of subdirectories.
The top level of these directories gets created in the [Targetdir] and the subdirectories in the root of C:
Does anyone know way to fix this without going to Installshield? It must be possible although I can't see too many options to choose from.
Happy programming!!
|
|
|
|
|
Forget it and go to InstallShield LE. It does a better job of EVERYTHING compared to the Setup and Deployment project.
The only way I know of, using the built in Setup and Deployment project, that can cause this is that you setup the folders in the project to be created off of some root folder, such as SystemDrive.
|
|
|
|
|
Hi,
I'm working with two datables in the same dataset. My first Table is 'Address_Table' which contains a_id (which is PK), s_id (which is FK referencing 'Students' Table S_ID), address, city state, zip. (which are displayed in text boxes) My second table 'Students' contains S_ID (PK), Name, Degree,Class, Percentage (Which are displayed in a Grid). My Question when i enter the text in the texboxes and in GridView and Click 'Save' both those data needs to stored into the 'Address_Table' and 'Students' respectively. I'm having no problems saving the data in the gridview but however getting this error at this line when i'm trying to send the textboxes.
this.address_TableTableAdapter.Fill(this.studentsDataSet.Address_Table,txtAddress.Text, txtCity.Text, cboState.Text,txtZip.Text); //No overload takes 5 arguments error.
Let me know if i did something wrong or if i have to add some more stuff Thanks
Sai
Here is the code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace students_normalization
{
public partial class DegreeForm : Form
{
public DegreeForm()
{
InitializeComponent();
}
private void DegreeForm_Load(object sender, EventArgs e)
{
this.address_TableTableAdapter.Fill(this.studentsDataSet.Address_Table);
try
{
this.studentsTableAdapter.Fill(this.studentsDataSet.Students);
}
catch (SqlException ex)
{
MessageBox.Show("Database Error # " + ex.Number + ": " + ex.Message, ex.GetType().ToString());
}
}
private void btnSave_Click(object sender, EventArgs e)
{
if(MessageBox.Show("Do you want to Save or Update a record","Update Record",MessageBoxButtons.YesNo) == DialogResult.Yes)
{
this.Validate();
this.studentsBindingSource.EndEdit();
this.addressTableBindingSource.EndEdit();
this.studentsTableAdapter.Update(this.studentsDataSet);
this.address_TableTableAdapter.Update(this.studentsDataSet);
this.studentsTableAdapter.Fill(this.studentsDataSet.Students);
this.address_TableTableAdapter.Fill(this.studentsDataSet.Address_Table,txtAddress.Text, txtCity.Text, cboState.Text,txtZip.Text);
}
}
private void btnCancel_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Do you want to Cancel", "Cancel", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
this.studentsBindingSource.CancelEdit();
}
}
private void btnDelete_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Do you want to Delete the Record", "Delete Record", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
this.studentsBindingSource.RemoveCurrent();
this.studentsTableAdapter.Update(this.studentsDataSet);
}
}
}
}
|
|
|
|
|
|
Intellisense do not give you any hints?
No more Mister Nice Guy... >: |
|
|
|
|
|
I think i figured it out how to do.
First thing i set up the textbox properties of the texboxes to binding source next thing i used this code
this.txtAge.DataBindings[0].ReadValue();
this.txtAddress.DataBindings[0].ReadValue();
this.txtCity.DataBindings[0].ReadValue();
this.cboState.DataBindings[0].ReadValue();
this.txtZip.DataBindings[0].ReadValue();
something like this
It worked fine
thanks for the help everyone
Sai
|
|
|
|
|
hi,
I'm developing a web application for my graduation project and it's my first time to use asp.net and C# , the problem is I have an essential part of a code written in C and I need it to be converted or embedded in my project.
I found a couple of converters but they all say that they are not reliable, another problem is that the C code has LOTS of pointers and I'm afraid that I'll mess things up..
is there a reliable converter or a reliable way ? or anyone who can compare both and make sure that they are right ?
Thanks
|
|
|
|
|
To ensure that your C# works properly, you'll probably need to translate the code manually.
The pointers issue isn't really that big a deal, but will require a great deal of diligence and accuracy in your translation. I've never trusted auto-converters between languages. I find they tend to introduce some pretty crazy and hard to find bugs.
I wasn't, now I am, then I won't be anymore.
|
|
|
|