TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Yadlapalli Srikanth
NA
272
82.8k
Function comaparison
May 29 2014 12:40 AM
I need to split the count exactly into 9 partitions if contains any remainder it should be appended to last partition. I have created two functions ideally both are same.Kindly suggest which will be the best way to implement and why.
Function 1
public static int trustcheck(int totalRows, int rowCount)
{
if (rowCount != 0 && (rowCount % (totalRows / 9)).Equals(0))
{
if (((totalRows % (totalRows / 9)) + rowCount).Equals(totalRows))
{
return 0;
}
else
{
return 1;
}
}
else
{
if (rowCount.Equals(totalRows))
return 1;
else
return 0;
}
}
Function2
public static int trustcheck2(int totalRows, int rowCount)
{
return (rowCount != 0 && (rowCount % (totalRows / 9)).Equals(0)) ? (((totalRows % (totalRows / 9)) + rowCount).Equals(totalRows) ? 0 : 1) : ((rowCount.Equals(totalRows)) ? 1 : 0);
}
Main Method
static void Main(string[] args)
{
trustcheck(105, 105);
ArrayList lst = new ArrayList();
for (int k = 0; k <= 105; k++)
{
if (trustcheck2(105, k) > 0)
{
lst.Add(k);
}
}
}
Reply
Answers (
4
)
code required to connect MS Access DB
Reminder